虽然网上都有资料查询,但是都是单一问题,为了大家节省时间特意收集整理,多多点赞
1、首先确保是最新的库,因为最新的库修复了“”No module named 'tools'“问题,旧的代码库采用的是动态加载
__dir__ = os.path.dirname(__file__)
import paddle
sys.path.append(os.path.join(__dir__, ''))
def _import_file(module_name, file_path, make_importable=False):
spec = importlib.util.spec_from_file_location(module_name, file_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
if make_importable:
sys.modules[module_name] = module
return module
tools = _import_file(
'tools', os.path.join(__dir__, 'tools\__init__.py'), make_importable=True)
ppocr = importlib.import_module('ppocr', 'paddleocr')
ppstructure = importlib.import_module('ppstructure', 'paddleocr')
2、使用pyinstaller -collect-all paddleocr --onefile main.py
3、找到spec文件在hiddenimports 添加
hiddenimports=['framework_pb2','scipy.special.cython_special','