pyinstaller打包一个demo.py报错 #13095
Unanswered
leizhu1989
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
镜像源:paddlepaddle/paddle:latest-dev
python:3.9
pyinstaller:6.3.0
打包命令行:pyinstaller -n paddleocrtest --distpath=/paddle/PaddleOCR/dist --clean --onefile --hidden-import imghdr --hidden-import imgaug --hidden-import pyclipper --collect-data paddle --collect-all paddleocr /paddle/PaddleOCR/demo.py
demo内容:
from paddleocr import PaddleOCR, draw_ocr
import os
import time
import cv2
Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
例如
ch
,en
,fr
,german
,korean
,japan
ocr = PaddleOCR(ocr_version="PP-OCRv3", lang="ch") # need to run only once to download and load model into memory
#img_path = '/paddle/test_image/QQ20240611092801.png'
#result = ocr.ocr(img_path, cls=True)
#for idx in range(len(result)):
res = result[idx]
for line in res:
print(line)
image_path = "/paddle/test_image"
list_img = os.listdir(image_path)
total_time = 0
txt_save = "/paddle/result/"
image_save = "/paddle/result/"
img_num = len(list_img)
for img in list_img:
full_path = image_path + "/" + img
avg_time = total_time / img_num
print("avg time: ", avg_time)
打包时报错信息,不知道是什么原因:
53422 INFO: Loading module hook 'hook-gi.repository.GObject.py' from '/usr/local/lib/python3.9/dist-packages/PyInstaller/hooks'...
53588 INFO: Loading module hook 'hook-gi.repository.GLib.py' from '/usr/local/lib/python3.9/dist-packages/PyInstaller/hooks'...
53636 WARNING: Hidden import "importlib_resources.trees" not found!
53776 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from '/usr/local/lib/python3.9/dist-packages/PyInstaller/hooks'...
53799 INFO: Loading module hook 'hook-matplotlib.backends.py' from '/usr/local/lib/python3.9/dist-packages/PyInstaller/hooks'...
53800 INFO: Matplotlib backend selection method: automatic discovery of used backends
53810 INFO: Discovered Matplotlib backend(s) via
matplotlib.use()
call in module 'paddle.dataset.uci_housing': ['Agg']53814 INFO: The following Matplotlib backends were discovered by scanning for
matplotlib.use()
calls: ['Agg']. If your backend of choice is not in this list, either add amatplotlib.use()
call to your code, or configure the backend collection via hook options (see: https://pyinstaller.org/en/stable/hooks-config.html#matplotlib-hooks).53814 INFO: Selected matplotlib backends: ['Agg']
53818 INFO: Loading module hook 'hook-scipy.special._ellip_harm_2.py' from '/usr/local/lib/python3.9/dist-packages/PyInstaller/hooks'...
53878 INFO: Performing binary vs. data reclassification (2498 entries)
54035 INFO: Looking for ctypes DLLs
54223 WARNING: Library user32 required via ctypes not found
54634 WARNING: Library msvcrt required via ctypes not found
Traceback (most recent call last):
File "/usr/local/bin/pyinstaller", line 8, in
sys.exit(_console_script_run())
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/main.py", line 214, in _console_script_run
run()
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/main.py", line 198, in run
run_build(pyi_config, spec_file, **vars(args))
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/main.py", line 69, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/building/build_main.py", line 1071, in main
build(specfile, distpath, workpath, clean_build)
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/building/build_main.py", line 1011, in build
exec(code, spec_namespace)
File "/paddle/PaddleOCR/paddleocrtest.spec", line 13, in
a = Analysis(
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/building/build_main.py", line 470, in init
self.postinit()
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/building/datastruct.py", line 184, in postinit
self.assemble()
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/building/build_main.py", line 683, in assemble
for (dest, source) in format_binaries_and_datas(self.graph.metadata_required()))
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/depend/analysis.py", line 775, in metadata_required
out |= self._metadata_from(
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/depend/analysis.py", line 834, in _metadata_from
out.update(copy_metadata(package))
File "/usr/local/lib/python3.9/dist-packages/PyInstaller/utils/hooks/init.py", line 973, in copy_metadata
dest_path = os.path.join(*src_path.parts[-2:])
AttributeError: 'Path' object has no attribute 'parts'
Beta Was this translation helpful? Give feedback.
All reactions