簡體   English   中英

pyinstaller ModuleNotFoundError:沒有名為“槳”的模塊

[英]pyinstaller ModuleNotFoundError: No module named 'paddle'

我正在使用 pyinstaller 在 windows 上創建 exe 文件。 我創建了基於 anaconda 的虛擬環境“py38”,並在其中安裝了所有軟件包。 我正在嘗試轉換一個 tkinter 文件,即“gui.py”。當我使用正常運行時

python gui.py

命令,它工作得很好。 但是使用 pyinstaller 似乎找不到我使用以下兩個命令安裝的模塊“槳”。

python -m pip download paddlepaddle==2.1.2 -f https://www.paddlepaddle.org.cn/whl/windows/mkl/noavx/stable.html --no-index --no-deps
python -m pip install [name].whl

我一直在使用 python 3.8。 我已經使用了幾乎所有可以在線解決此問題的可能解決方案。

我嘗試過的命令來修復它

pyinstaller --paths 'C:\\Users\\user\\anaconda3\\envs\\py38\\lib\\site-packages' --onefile --clean gui.py
pyinstaller --paths 'C:\\Users\\user\\anaconda3\\envs\\py38\\lib\\site-packages' --onedir gui.py
pyinstaller --hidden-import 'paddle' --onefile --clean gui.py
pyinstaller --hidden-import 'paddlepaddle' --onefile --clean gui.py
pyinstaller --hidden-import 'paddlepaddle' --onedir --clean gui.py

當我使用--onedir時,生成的 exe 文件也會在啟動后立即關閉。 下面給出了完整的日志,當我運行指定了“--paths”的pyinstaller時

>pyinstaller --paths 'C:\\Users\\user\\anaconda3\\envs\\py38\\lib\\site-packages' --onefile --clean gui.py
586 INFO: PyInstaller: 4.5.1
587 INFO: Python: 3.8.11 (conda)
605 INFO: Platform: Windows-10-10.0.19041-SP0
610 INFO: wrote C:\Users\user\Downloads\recognizer\gui.spec
614 INFO: UPX is not available.
615 INFO: Removing temporary files and cleaning cache in C:\Users\user\AppData\Local\pyinstaller
631 INFO: Extending PYTHONPATH with paths
['C:\\Users\\user\\Downloads\\recognizer',
 "C:\\Users\\user\\Downloads\\recognizer\\'C:\\Users\\user\\anaconda3\\envs\\py38\\lib\\site-packages'",
 'C:\\Users\\user\\Downloads\\recognizer']
1560 INFO: checking Analysis
1561 INFO: Building Analysis because Analysis-00.toc is non existent
1561 INFO: Initializing module dependency graph...
1569 INFO: Caching module graph hooks...
1620 INFO: Analyzing base_library.zip ...
8791 INFO: Processing pre-find module path hook distutils from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
8794 INFO: distutils: retargeting to non-venv dir 'c:\\users\\user\\anaconda3\\envs\\py38\\lib'
16752 INFO: Caching module dependency graph...
17497 INFO: running Analysis Analysis-00.toc
17507 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\user\anaconda3\envs\py38\python.exe
18231 INFO: Analyzing C:\Users\user\Downloads\recognizer\gui.py
22037 INFO: Processing pre-find module path hook site from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
22042 INFO: site: retargeting to fake-dir 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\fake-modules'
33819 INFO: Processing module hooks...
33822 INFO: Loading module hook 'hook-cv2.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
33832 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
33837 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
33839 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
33845 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34078 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34089 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34191 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34196 INFO: Loading module hook 'hook-numpy.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34318 WARNING: Conda distribution 'numpy', dependency of 'numpy', was not found. If you installed this distribution with pip then you may ignore this warning.
34432 INFO: Import to be excluded not found: 'f2py'
34508 INFO: Loading module hook 'hook-numpy._pytesttester.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34514 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
34519 INFO: Loading module hook 'hook-PIL.Image.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
35422 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
35428 INFO: Loading module hook 'hook-PIL.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
35464 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
35470 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
37159 INFO: Processing pre-safe import module hook win32com from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
37315 WARNING: Hidden import "pkg_resources.py2_warn" not found!
37317 WARNING: Hidden import "pkg_resources.markers" not found!
37322 INFO: Loading module hook 'hook-PyQt5.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
37926 WARNING: Hidden import "sip" not found!
37931 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
38168 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
38743 INFO: Loading module hook 'hook-scipy.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
38756 INFO: Loading module hook 'hook-setuptools.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
40669 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
40673 INFO: Loading module hook 'hook-win32ctypes.core.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41174 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41177 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41179 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41180 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
41557 INFO: checking Tree
41557 INFO: Building Tree because Tree-00.toc is non existent
41561 INFO: Building Tree Tree-00.toc
41752 INFO: checking Tree
41756 INFO: Building Tree because Tree-01.toc is non existent
41757 INFO: Building Tree Tree-01.toc
42025 INFO: checking Tree
42030 INFO: Building Tree because Tree-02.toc is non existent
42031 INFO: Building Tree Tree-02.toc
42048 INFO: Loading module hook 'hook-setuptools.msvc.py' from 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks'...
42153 INFO: Looking for ctypes DLLs
42340 INFO: Analyzing run-time hooks ...
42354 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
42366 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
42374 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
42379 INFO: Including run-time hook 'c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
42417 INFO: Looking for dynamic libraries
43704 INFO: Looking for eggs
43706 INFO: Using Python library c:\users\user\anaconda3\envs\py38\python38.dll
43708 INFO: Found binding redirects:
[]
43723 INFO: Warnings written to C:\Users\user\Downloads\recognizer\build\gui\warn-gui.txt
44000 INFO: Graph cross-reference written to C:\Users\user\Downloads\recognizer\build\gui\xref-gui.html
44146 INFO: checking PYZ
44149 INFO: Building PYZ because PYZ-00.toc is non existent
44150 INFO: Building PYZ (ZlibArchive) C:\Users\user\Downloads\recognizer\build\gui\PYZ-00.pyz
46686 INFO: Building PYZ (ZlibArchive) C:\Users\user\Downloads\recognizer\build\gui\PYZ-00.pyz completed successfully.
46773 INFO: checking PKG
46775 INFO: Building PKG because PKG-00.toc is non existent
46777 INFO: Building PKG (CArchive) PKG-00.pkg
92228 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
92319 INFO: Bootloader c:\users\user\anaconda3\envs\py38\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
92321 INFO: checking EXE
92321 INFO: Building EXE because EXE-00.toc is non existent
92322 INFO: Building EXE from EXE-00.toc
92326 INFO: Copying icons from ['c:\\users\\user\\anaconda3\\envs\\py38\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
92461 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
92461 INFO: Writing RT_ICON 1 resource with 3752 bytes
92462 INFO: Writing RT_ICON 2 resource with 2216 bytes
92462 INFO: Writing RT_ICON 3 resource with 1384 bytes
92462 INFO: Writing RT_ICON 4 resource with 37019 bytes
92462 INFO: Writing RT_ICON 5 resource with 9640 bytes
92462 INFO: Writing RT_ICON 6 resource with 4264 bytes
92462 INFO: Writing RT_ICON 7 resource with 1128 bytes
92510 INFO: Updating manifest in C:\Users\user\Downloads\recognizer\build\gui\run.exe.s5i_qt6_
92651 INFO: Updating resource type 24 name 1 language 0
92656 INFO: Appending archive to EXE C:\Users\user\Downloads\recognizer\dist\gui.exe
139969 INFO: Building EXE from EXE-00.toc completed successfully.

(py38) C:\Users\user\Downloads\recognizer>

我在 exe window 上顯示的錯誤如下: 在此處輸入圖像描述

我還創建了兩次全新的 conda 環境,並重新安裝了所有軟件包,即使這樣也沒有解決問題。

如果有人可以幫助我,那將不勝感激

如果其他庫運行良好並且問題僅出在 paddleOCR 上,請嘗試: pip install paddlepaddle paddleocr

我面臨同樣的錯誤。 好的步驟可以如下

  1. pip install paddleocr --upgrade
  2. pip install paddlepaddle

參考https://github.com/PaddlePaddle/PaddleOCR/issues/1265#issuecomment-748429488

這解決了我的問題。 謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM