我刚刚从Python 2.7升级到Python 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
错误信息建议先运行'python setup.py build_ext --inplace --force'来导入panda。我应该在哪里运行这个程序?如果我从cmd运行它,它找不到setup.py文件?
1条答案
按热度按时间sr4lhrrt1#
谢谢!
向.spec文件添加以下行解决了该问题: