pyinstaller ModuleNotFoundError:没有名为“桨”的模块

我正在使用 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:Usersuseranaconda3envspy38libsite-packages' --onefile --clean gui.py
pyinstaller --paths 'C:Usersuseranaconda3envspy38libsite-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:Usersuseranaconda3envspy38libsite-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:UsersuserDownloadsrecognizergui.spec
614 INFO: UPX is not available.
615 INFO: Removing temporary files and cleaning cache in C:UsersuserAppDataLocalpyinstaller
631 INFO: Extending PYTHONPATH with paths
['C:UsersuserDownloadsrecognizer',
 "C:UsersuserDownloadsrecognizer'C:Usersuseranaconda3envspy38libsite-packages'",
 'C:UsersuserDownloadsrecognizer']
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:usersuseranaconda3envspy38libsite-packagesPyInstallerhookspre_find_module_pathhook-distutils.py'.
8794 INFO: distutils: retargeting to non-venv dir 'c:usersuseranaconda3envspy38lib'
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:usersuseranaconda3envspy38python.exe
18231 INFO: Analyzing C:UsersuserDownloadsrecognizergui.py
22037 INFO: Processing pre-find module path hook site from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhookspre_find_module_pathhook-site.py'.
22042 INFO: site: retargeting to fake-dir 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerfake-modules'
33819 INFO: Processing module hooks...
33822 INFO: Loading module hook 'hook-cv2.py' from 'c:usersuseranaconda3envspy38libsite-packages_pyinstaller_hooks_contribhooksstdhooks'...
33832 INFO: Loading module hook 'hook-difflib.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
33837 INFO: Loading module hook 'hook-distutils.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
33839 INFO: Loading module hook 'hook-distutils.util.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
33845 INFO: Loading module hook 'hook-encodings.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
34078 INFO: Loading module hook 'hook-heapq.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
34089 INFO: Loading module hook 'hook-lib2to3.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
34191 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
34196 INFO: Loading module hook 'hook-numpy.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
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:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
34514 INFO: Loading module hook 'hook-pickle.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
34519 INFO: Loading module hook 'hook-PIL.Image.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
35422 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
35428 INFO: Loading module hook 'hook-PIL.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
35464 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
35470 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
37159 INFO: Processing pre-safe import module hook win32com from 'c:usersuseranaconda3envspy38libsite-packages_pyinstaller_hooks_contribhookspre_safe_import_modulehook-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:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
37926 WARNING: Hidden import "sip" not found!
37931 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
38168 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
38743 INFO: Loading module hook 'hook-scipy.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
38756 INFO: Loading module hook 'hook-setuptools.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
40669 INFO: Loading module hook 'hook-sysconfig.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
40673 INFO: Loading module hook 'hook-win32ctypes.core.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
41174 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
41177 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
41179 INFO: Loading module hook 'hook-xml.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
41180 INFO: Loading module hook 'hook-_tkinter.py' from 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
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:usersuseranaconda3envspy38libsite-packagesPyInstallerhooks'...
42153 INFO: Looking for ctypes DLLs
42340 INFO: Analyzing run-time hooks ...
42354 INFO: Including run-time hook 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooksrthookspyi_rth_pkgutil.py'
42366 INFO: Including run-time hook 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooksrthookspyi_rth_multiprocessing.py'
42374 INFO: Including run-time hook 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooksrthookspyi_rth_inspect.py'
42379 INFO: Including run-time hook 'c:usersuseranaconda3envspy38libsite-packagesPyInstallerhooksrthookspyi_rth__tkinter.py'
42417 INFO: Looking for dynamic libraries
43704 INFO: Looking for eggs
43706 INFO: Using Python library c:usersuseranaconda3envspy38python38.dll
43708 INFO: Found binding redirects:
[]
43723 INFO: Warnings written to C:UsersuserDownloadsrecognizerbuildguiwarn-gui.txt
44000 INFO: Graph cross-reference written to C:UsersuserDownloadsrecognizerbuildguixref-gui.html
44146 INFO: checking PYZ
44149 INFO: Building PYZ because PYZ-00.toc is non existent
44150 INFO: Building PYZ (ZlibArchive) C:UsersuserDownloadsrecognizerbuildguiPYZ-00.pyz
46686 INFO: Building PYZ (ZlibArchive) C:UsersuserDownloadsrecognizerbuildguiPYZ-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:usersuseranaconda3envspy38libsite-packagesPyInstallerbootloaderWindows-64bitrun.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:usersuseranaconda3envspy38libsite-packagesPyInstallerbootloaderimagesicon-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:UsersuserDownloadsrecognizerbuildguirun.exe.s5i_qt6_
92651 INFO: Updating resource type 24 name 1 language 0
92656 INFO: Appending archive to EXE C:UsersuserDownloadsrecognizerdistgui.exe
139969 INFO: Building EXE from EXE-00.toc completed successfully.

(py38) C:UsersuserDownloadsrecognizer>

我在 exe 窗口上显示的错误如下: enter image description here

我还创建了两次全新的 conda 环境,并重新安装了所有软件包,即使这样也没有解决问题。

如果有人可以帮助我,那将不胜感激

stack overflow pyinstaller ModuleNotFoundError: No module named 'paddle'
原文答案

答案:

作者头像

如果其他自由派效果很好,并且问题仅在Paddleocr上,请尝试:PIP安装PaddlePaddle Paddleocr

相关问题