From e5cb6178fc98fe33364cf489801298cf7d4390c0 Mon Sep 17 00:00:00 2001 From: wuzewu Date: Tue, 1 Dec 2020 16:26:37 +0800 Subject: [PATCH] Fix model installation failure caused by coding problems under windows --- paddlehub/module/module.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paddlehub/module/module.py b/paddlehub/module/module.py index a9413a773..d6eb377ff 100644 --- a/paddlehub/module/module.py +++ b/paddlehub/module/module.py @@ -15,6 +15,7 @@ import ast import builtins +import codecs import inspect import os import re @@ -107,7 +108,7 @@ def get_py_requirements(cls) -> List[str]: req_file = os.path.join(directory, 'requirements.txt') if not os.path.exists(req_file): return [] - with open(req_file, 'r') as file: + with codecs.open(req_file, 'r', encoding='utf8') as file: return file.read().split('\n') @property @@ -229,7 +230,7 @@ def load_module_info(cls, directory: str) -> EasyDict: # If is ModuleV2 module_file = os.path.join(directory, 'module.py') - with open(module_file, 'r') as file: + with codecs.open(module_file, 'r', encoding='utf8') as file: pycode = file.read() ast_module = ast.parse(pycode)