虽然网上都有资料查询,但是都是单一问题,为了大家节省时间特意收集整理,多多点赞

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','skimage','skimage.feature._orb_descriptor_positions','skimage.filters.edges', 'skimage.data._fetchers']

4、进入paddleocr修改

from ppstructure.predict_system import StructureSystem, save_structure_res, to_excel

from ppstructure.predict_system import StructureSystem, save_structure_res, to_excel,TextSystem

class PaddleOCR(predict_system.TextSystem)

class PaddleOCR(TextSystem)

5、pyinstaller main.spec

上面打包成功后会出现缺少mklml.dll文件,此文件在\paddle\libs 里面所以可以单独加载它也可以

可以用以下spec:

block_cipher = None
a = Analysis(['main.py'],
     pathex=['E:\\PyEnviroment\\Lib\\site-packages\\paddleocr', 'E:\\PyEnviroment\\Lib\\site-packages\\paddle\\libs'],
     binaries=[('E:\\PyEnviroment\\Lib\\site-packages\\paddle\\libs', '.')],
     datas=[],
     hiddenimports=['framework_pb2','scipy.special.cython_special','skimage','skimage.feature._orb_descriptor_positions','skimage.filters.edges', 'skimage.data._fetchers'],
     hookspath=['.'],
     runtime_hooks=[],
     excludes=['matplotlib'],
     win_no_prefer_redirects=False,
     win_private_assemblies=False,
     cipher=block_cipher,
     noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
     cipher=block_cipher)
exe = EXE(pyz,
     a.scripts,
     [],
     exclude_binaries=True,
     name='main',
     debug=False,
     bootloader_ignore_signals=False,
     strip=False,
     upx=True,
     console=True)
coll = COLLECT(exe,
     a.binaries,
     a.zipfiles,
     a.datas,
     strip=False,
     upx=True,
     upx_exclude=[],
     name='main')

GitHub 加速计划 / pa / PaddleOCR
75
11
下载
Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
最近提交(Master分支:8 个月前 )
a80d2c89 4 天前
5d120f8f 7 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐