我刚从Python 2.7升级到3.6。 我有一个带有GUI的相当大的脚本,我已经冻结到带有pyinstaller的.exe文件。
我现在对.py脚本进行了一些更改,并且在冻结之前它适用于新的Python版本。
然而,当我冻结时,我得到一个"无法执行脚本"信息。 我试着查看错误代码,并将问题追溯到Pandas模块。以下是错误消息:
C:\Users\MRCH\dist>My_File.exe
Traceback (most recent call last):
File "site-packages\pandas\__init__.py", line 26, in <module>
File "c:\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pandas\_libs\__init__.py", line 4, in <module>
File "c:\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
File "pandas/_libs/tslib.pyx", line 1, in init pandas._libs.tslib
ModuleNotFoundError: No module named 'pandas._libs.tslibs.timedeltas'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "My_File.py", line 6, in <module>
File "c:\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pandas\__init__.py", line 35, in <module>
ImportError: C extension: No module named 'pandas._libs.tslibs.timedeltas' not built.
**If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.**
[2032] Failed to execute script My_File
错误消息建议通过运行&#39; python setup.py build_ext --inplace --force&#39;来导入pandas。第一。我会在哪里运行?如果我从cmd运行它,它找不到setup.py文件?
答案 0 :(得分:2)
@apogalacticon谢谢!
将以下行添加到.spec文件中解决了问题:
hiddenimports = ['pandas._libs.tslibs.timedeltas']