解决pyinstaller 打包后运行exe程序出现的"ModuleNotFindError"
2018-03-15 08:59
931 查看
在用pyinstaller打包python程序
pyinstaller版本为:3.3.1
python 版本:3.6.1
系统版本:Windows-10-10.0.16299-SP0
我的python程序名为:data_processing_gui.py
程序在python环境下正常运行。
打包使用的格式为:pyinstaller -F -p <导入的包路径> myprogram.py
完整打包命令为:
打包过程无报错,打包完成后运行程序提示出错信息:
最后在Stackoverflow上发现了一个类似问题,最终解决了问题
解决方案是:
接下来,使用文本编辑器打开”.spec”文件,在
然后使用
最终,问题解决。
这里有Stackoverflow 上我的问题:https://stackoverflow.com/questions/49232117/using-pyinstaller-to-package-python-program-and-there-is-a-nomodulefinderror/49289859#49289859
这里是找到答案的位置:https://stackoverflow.com/questions/47607315/modulenotfounderror-no-module-named-pandas-libs-tslibs-timedeltas
pyinstaller版本为:3.3.1
python 版本:3.6.1
系统版本:Windows-10-10.0.16299-SP0
我的python程序名为:data_processing_gui.py
程序在python环境下正常运行。
打包使用的格式为:pyinstaller -F -p <导入的包路径> myprogram.py
完整打包命令为:
pyinstaller -F -p C:\Users\fanyu\Anaconda3\Lib;C:\Users\fanyu\Anaconda3\Lib\site-packages;C:\Users\fanyu\Anaconda3\Lib\site-packages\PyQt5\Qt\bin;C:\Users\fanyu\Anaconda3\Lib\site-packages\pydicom;C:\Users\fanyu\Anaconda3\Lib\site-packages\radiomics;C:\Users\fanyu\Anaconda3\Lib\site-packages\pywt;C:\Users\fanyu\Anaconda3\Lib\site-packages\pywt\_extensions;C:\Users\fanyu\Anaconda3\Lib\site-packages\tensorflow;C:\Users\fanyu\Anaconda3\Lib\site-packages\SimpleITK;C:\Users\fanyu\Anaconda3\Lib\site-packages\PIL;C:\Users\fanyu\Anaconda3\Lib\site-packages\pandas;C:\Users\fanyu\Anaconda3\Lib\site-packages\nrrd;C:\Users\fanyu\Anaconda3\Lib\site-packages\numpy -i C:\Users\fanyu\Desktop\work\package\image\doctor.ico data_processing_gui.py pause
打包过程无报错,打包完成后运行程序提示出错信息:
Traceback (most recent call last): File "data_processing_gui.py", line 12, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\radiomics\__init__.py", line 15, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\radiomics\imageoperations.py", line 6, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pywt\__init__.py", line 17, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pywt\_functions.py", line 17, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module module = loader.load_module(fullname) File "pywt/_extensions/_pywt.pyx", line 1, in init pywt._extensions._pywt (pywt\_extensions\_pywt.c:31281) ModuleNotFoundError: No module named 'pywt._extensions._cwt' [7564] Failed to execute script data_processing_gui
最后在Stackoverflow上发现了一个类似问题,最终解决了问题
解决方案是:
首先,使用pyinstaller 打包生成”.spec” 文件
接下来,使用文本编辑器打开”.spec”文件,在 hiddenimport=[]
部分添加缺少的module,我的程序中缺少的是 pywt
模块,因而添加:
hiddenimport=[ "pywt","pywt._extensions._cwt"]
然后使用pyinstaller
生成新的exe程序:
pyinstaller my.spec
最终,问题解决。
这里有Stackoverflow 上我的问题:https://stackoverflow.com/questions/49232117/using-pyinstaller-to-package-python-program-and-there-is-a-nomodulefinderror/49289859#49289859
这里是找到答案的位置:https://stackoverflow.com/questions/47607315/modulenotfounderror-no-module-named-pandas-libs-tslibs-timedeltas
相关文章推荐
- Android studio中打包apk出现"XXX" is translated here but not found in default locale的解决问题的方法
- 如何解决 X-code5.0中的iOS7.0SDK运行程序时,出现的以下问题:“Could not find a storyboard named 'Main' in bundle NSBundle”
- 解决打开Android SDK Manager时出现“.....\sdk\tools\lib\\find_java.exe不是内部或外部命令,也不是可运行的程序或批处理文件“问题
- 在Eclipse中运行C++程序出现"Launchfailed. Binary not foud"和"Program file notSpecified"的问题
- 关于clover2运行时出现的"annotations are not supported in -source 1.3"错误的解决
- (上一篇的问题解决后又遇到的新问题)在eclipse中导入工程后运行任意文件出现"The selection is not within a valid module"
- 在centos中运行java命令时出现Error: Could not find or load main class XXX问题的解决方法
- QT运行exe时出现“could not find or load the QT platform plugin windows”问题的解决办法
- 在Eclipse中运行C++程序出现"Launch failed. Binary not foud"和"Program file not Specified"的问题
- MPI编译C++程序出现#error "SEEK_SET is #defined but must not be for the C++ binding of MPI" 的解决方法
- 安装并运行apk时出现恼人的"Error: Activity class {xxx/xxx.MainActivity} does not exist."
- MPI编译C++程序出现#error "SEEK_SET is #defined but must not be for the C++ binding of MPI" 的解决方法
- 解决SQL2000出现"无法执行查询,因为文件缺少或未注册。再次运行安装程序确保要求的文件已注册。"的方法
- 关于JCreator在编译程序时出现的"Error:Invalid path"问题的解决方法
- 解决Windows server 2012 R2 系统使用IIS8浏览Asp程序出现"An error occurred on the server when processing the URL"错误
- SlickEdit在64bit Ubuntu下运行vsinst安装程序出现"No such file or directory"的解决方法
- 运行的程序时,出现内存不足时的解决方式Exception in thread "main" java.lang.OutOfMemoryError: Java heap space(转)
- VS2005运行程序时出现“没有找到MSVCP80D.dll"错误的解决方法
- 解决Windows下PIL库的"The _imagingft C module is not installed"错误
- Xcode7.0beta真机调试出现"Could not find Developer Disk Image"揭示