在python中使用pyinstaller 生成exe文件后,使用时报错:
Traceback (most recent call last):
File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_mplconfig.py", line 45, in <module>
File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_mplconfig.py", line 31, in _pyi_rthook
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "PyInstaller\fake-modules\_pyi_rth_utils\_win32.py", line 12, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "ctypes\__init__.py", line 8, in <module>
ImportError: DLL load failed while importing _ctypes: 找不到指定的模块。
解决方法:
使用everything 或 查看自己使用的anaconda虚拟环境文件夹中,找到ffi.dll:
复制一份到
所属项目的.\dist\ProjectName\_internal 中。
-----------------------------------------------------------------------------
更好的方式:
pyinstaller --onefile --add-data "F:\Anaconda3\envs\py3106\Library\bin\ffi.dll;." xx.py