冻结问题 Python Pandas

Issues with freezing Python Pandas

我刚从 Python 2.7 升级到 3.6。 我有一个相当大的带有 GUI 的脚本,我用 pyinstaller 将其冻结为一个 .exe 文件。

我现在对 .py 脚本做了一些更改,在我冻结它之前它可以与新的 Python 版本一起使用。

但是,当我冻结时,我收到 "Failed to execute script" 消息。 我试图查看错误代码,并将问题追溯到 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'导入pandas。我在哪里 运行 这个?如果我从 cmd 运行 它找不到 setup.py 文件?

@apogalacticon 谢谢!

将以下行添加到 .spec 文件解决了问题:

hiddenimports = ['pandas._libs.tslibs.timedeltas']