diff --git a/paddlehub/module/module.py b/paddlehub/module/module.py index a9413a773e845f1b3ef657383422d480f9f4aa16..d6eb377ff7587a718c24632d0be896c1b8180eda 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 @@ class RunModule(object): 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 @@ class Module(object): # 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)