Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paddleocr infer_rec打包失败framework_pb2 #5326

Closed
that-learner opened this issue Jan 24, 2022 · 15 comments
Closed

paddleocr infer_rec打包失败framework_pb2 #5326

that-learner opened this issue Jan 24, 2022 · 15 comments
Assignees

Comments

@that-learner
Copy link

PaddleOCR识别模型打包正常,运行报错No module named 'framework_pb2 pyinstaller -F infer_rec.py
记录于2022/1/24

  • 系统环境/windows 64bit:
  • 版本号/PaddleOCR:paddlepaddle==2.2
  • 运行指令/Command Code:打包的dist文件夹运行infer_rec.exe
  • 完整报错/ File "paddle\fluid\proto\pass_desc_pb2.py", line 15, in
    ModuleNotFoundError: No module named 'framework_pb2'
@andyjiang1116
Copy link
Collaborator

可否提供一下完整的报错信息?

@that-learner
Copy link
Author

(paddleocr) D:\PaddleOCR\tools\dist>infer_rec.exe
Traceback (most recent call last):
File "paddle\fluid\ir.py", line 23, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "paddle\fluid\proto\pass_desc_pb2.py", line 15, in
import framework_pb2 as framework__pb2
ModuleNotFoundError: No module named 'framework_pb2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "infer_rec.py", line 32, in
import paddle
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "paddle_init_.py", line 45, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "paddle\distributed_init_.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "paddle\distributed\spawn.py", line 24, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "paddle\distributed\utils.py", line 28, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "paddle\distributed\fleet_init_.py", line 20, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "paddle\distributed\fleet\base\fleet_base.py", line 31, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "paddle\fluid\ir.py", line 27, in
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "paddle\fluid\proto\pass_desc_pb2.py", line 15, in
import framework_pb2 as framework__pb2
ModuleNotFoundError: No module named 'framework_pb2'
[43652] Failed to execute script 'infer_rec' due to unhandled exception!

@xushengfeng
Copy link

我是将 site-packages/paddle/fluid/中的proto文件夹复制到生成的dist/paddle/fluid/下

@Kromtar
Copy link

Kromtar commented Mar 18, 2022

I have the same problem :(

@geoexploring
Copy link

我的这样改就可以了:

Lib\site-packages\paddle\fluid\proto\pass_desc_pb2.py下,将import framework_pb2 as framework__pb2改成import paddle.fluid.proto.framework_pb2 as framework__pb2

@myCout
Copy link

myCout commented Jun 8, 2022

@xushengfeng 试了下你的方案,我的还是报这个错;
@geoexploring 按照你的方式试了,报新的错误:
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "paddle_init_.py", line 71, in
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "paddle\dataset_init
.py", line 27, in
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "paddle\dataset\flowers.py", line 39, in
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "paddle\dataset\image.py", line 48, in
File "subprocess.py", line 829, in init
File "subprocess.py", line 1252, in _get_handles
OSError: [WinError 6] 句柄无效。
还得继续折腾。

@shoou
Copy link

shoou commented Jul 14, 2022

paddle\dataset\image.py has suppress process bug: it opens many processes. if you don't want cv2 you can change it like this:

source:

# FIXME(minqiyang): this is an ugly fix for the numpy bug reported here
# https://github.com/numpy/numpy/issues/12497
if six.PY3:
    import subprocess
    import sys
    import os
    interpreter = sys.executable
    # Note(zhouwei): if use Python/C 'PyRun_SimpleString', 'sys.executable'
    # will be the C++ execubable on Windows
    if sys.platform == 'win32' and 'python.exe' not in interpreter:
        interpreter = sys.exec_prefix + os.sep + 'python.exe'
    import_cv2_proc = subprocess.Popen(
        [interpreter, "-c", "import cv2"],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)
    out, err = import_cv2_proc.communicate()
    retcode = import_cv2_proc.poll()
    if retcode != 0:
        cv2 = None
    else:
        import cv2
else:
    try:
        import cv2
    except ImportError:
        cv2 = None

change to below:

try:
    import cv2
except:
    cv2 = None

@BND-lhr
Copy link

BND-lhr commented Oct 18, 2022

@shoou it works

@Mrfuhang
Copy link

Mrfuhang commented Apr 3, 2023

myCout

你那边可以了嘛

@Bug-Mr
Copy link

Bug-Mr commented May 24, 2023

所有的方法都用啦,还是报错,怎么解决?你们的模型需要导出来放到指定位置吗?

@Bug-Mr
Copy link

Bug-Mr commented May 24, 2023

第一,我是将 site-packages/paddle/fluid/中的proto文件夹复制到生成的dist/paddle/fluid/下
第二,Lib\site-packages\paddle\fluid\proto\pass_desc_pb2.py下,将import framework_pb2 as framework__pb2改成import paddle.fluid.proto.framework_pb2 as framework__pb2。

做完两步后报错:
`
Traceback (most recent call last):
File "main.py", line 1, in
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "paddleocr_init_.py", line 14, in
File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
File "paddleocr\paddleocr.py", line 33, in
File "importlib_init_.py", line 127, in import_module
ModuleNotFoundError: No module named 'tools'

`

@DYF-AI
Copy link

DYF-AI commented Dec 4, 2023

@xushengfeng 试了下你的方案,我的还是报这个错; @geoexploring 按照你的方式试了,报新的错误: File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module File "paddle__init__.py", line 71, in File "", line 1007, in _find_and_load File "", line 986, in find_and_load_unlocked File "", line 680, in load_unlocked File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module File "paddle\dataset__init.py", line 27, in File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module File "paddle\dataset\flowers.py", line 39, in File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module File "paddle\dataset\image.py", line 48, in File "subprocess.py", line 829, in init File "subprocess.py", line 1252, in _get_handles OSError: [WinError 6] 句柄无效。 还得继续折腾。

统一的问题,请教一下如何解决?

@Bug-Mr
Copy link

Bug-Mr commented Dec 4, 2023 via email

@DYF-AI
Copy link

DYF-AI commented Dec 4, 2023

第一,我是将 site-packages/paddle/fluid/中的proto文件夹复制到生成的dist/paddle/fluid/下 第二,Lib\site-packages\paddle\fluid\proto\pass_desc_pb2.py下,将import framework_pb2 as framework__pb2改成import paddle.fluid.proto.framework_pb2 as framework__pb2。

做完两步后报错: ` Traceback (most recent call last): File "main.py", line 1, in File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddleocr__init__.py", line 14, in File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module File "paddleocr\paddleocr.py", line 33, in File "importlib__init__.py", line 127, in import_module ModuleNotFoundError: No module named 'tools'

`

我也是,前两步都可以了,有出现如下问题:
(paddle) G:\dongyongfei786\multimodal-lm\third_party\ppocrlabel-pil\dist>PPOCRLabel.exe
Traceback (most recent call last):
File "ppocrlabel-pil\PPOCRLabel.py", line 41, in
from paddleocr import PaddleOCR, PPStructure
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "paddleocr_init
.py", line 14, in
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "paddleocr\paddleocr.py", line 43, in
File "paddleocr\paddleocr.py", line 37, in _import_file
File "", line 839, in exec_module
File "", line 975, in get_code
File "", line 1032, in get_data
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\21702\AppData\Local\Temp\_MEI271362\paddleocr\tools/init.py'
[7336] Failed to execute script 'PPOCRLabel' due to unhandled exception!

@Bug-Mr
Copy link

Bug-Mr commented Dec 4, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests