我已经编写了一个简单的 python 脚本,现在我正在尝试制作一个 exe 文件。每当我尝试运行生成的 exe 时,程序都会失败import pandas
我收到以下错误。
Traceback (most recent call last):
File "myProgram.py", line 14, in <module>
import pandas
File "c:\temp\pip-install-k4pegh\pyInstaller\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
File "site-packages\pandas\__init__.py", line 35, in <module>
ImportError: C extension: No module named tslib 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.
[492] Failed to execute script myProgram
查看 cmd 输出,hook-pandas 已加载。所以这不是 pyinstaller 找到 pandas 钩子的问题。
30240 INFO: Loading module hook "hook-pkg_resources.py"...
30568 INFO: Processing pre-safe import module hook win32com
31036 INFO: Loading module hook "hook-pytz.py"...
31286 INFO: Loading module hook "hook-pywintypes.py"...
31550 INFO: Loading module hook "hook-setuptools.py"...
31644 INFO: Loading module hook "hook-encodings.py"...
33516 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
33516 INFO: Loading module hook "hook-numpy.core.py"...
33609 INFO: Loading module hook "hook-sqlite3.py"...
33796 INFO: Loading module hook "hook-pandas.py"...
33812 INFO: Loading module hook "hook-win32com.py"...
34779 INFO: Loading module hook "hook-pythoncom.py"...
35217 INFO: Analyzing run-time hooks ...
35231 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
35247 INFO: Including run-time hook 'pyi_rth__tkinter.py'
35263 INFO: Including run-time hook 'pyi_rth_pkgres.py'
35279 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
我确实必须添加 pandas-hook 到Python27\Lib\site-packages\PyInstaller\hooks
我。看PyInstaller 中没有名为“pandas._libs.tslibs.timedeltas”的模块 https://stackoverflow.com/questions/47318119/no-module-named-pandas-libs-tslibs-timedeltas-in-pyinstaller and https://github.com/lneuhaus/pyinstaller/commit/017b247064f9bd51a620cfb2172c05d63fc75133 https://github.com/lneuhaus/pyinstaller/commit/017b247064f9bd51a620cfb2172c05d63fc75133。这会是一个问题吗?
早些时候我也尝试根据这个问题更改规范文件,PyInstaller 和 Pandas https://stackoverflow.com/questions/29109324/pyinstaller-and-pandas,没有运气。
Using:
python 2.7
pyinstaller 3.3.1
pandas 0.22.0.
如果有人知道为什么 pyinstaller 不能使用加载的钩子或者对下一步要尝试什么有任何想法,我将非常感激。