4

我正在尝试使用 pyinstaller 2.0 从使用 Pandas 的 Python 脚本创建可执行文件。

我有一个非常简单的测试脚本('hello.py'):

import pandas as pd

df = pd.DataFrame([1, 2, 3])
print df.mean()

Pyinstaller 似乎运行良好,除了一些警告:

PS C:\Users\<user>\Dropbox\pyinstaller-2.0> python .\pyinstaller.py .\hello.py
39 INFO: wrote C:\Users\<user>\Dropbox\pyinstaller-2.0\hello\hello.spec
61 INFO: Testing for ability to set icons, version resources...
67 INFO: ... resource update available
68 INFO: UPX is not available.
1468 WARNING: library python%s%s required via ctypes not found
1525 INFO: checking Analysis
1548 INFO: building because C:\Python27_32\lib\site-packages\pandas\util\decorators.pyc changed
1548 INFO: running Analysis out00-Analysis.toc
1549 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
2058 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
2059 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest
2061 INFO: Searching for file msvcr90.dll
2061 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll
2061 INFO: Searching for file msvcp90.dll
2062 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcp90.dll
2062 INFO: Searching for file msvcm90.dll
2062 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcm90.dll
2152 INFO: Analyzing C:\Users\<user>\Dropbox\pyinstaller-2.0\support\_pyi_bootstrap.py
3495 WARNING: library python%s%s required via ctypes not found
3537 INFO: Analyzing C:\Users\<user>\Dropbox\pyinstaller-2.0\PyInstaller\loader\archive.py
3685 INFO: Analyzing C:\Users\<user>\Dropbox\pyinstaller-2.0\PyInstaller\loader\carchive.py
3831 INFO: Analyzing C:\Users\<user>\Dropbox\pyinstaller-2.0\PyInstaller\loader\iu.py
3854 INFO: Analyzing .\hello.py
4884 INFO: checking Tree
4930 INFO: checking Tree
6183 WARNING: pythoncom is changing its name to pythoncom27
6206 WARNING: pywintypes is changing its name to pywintypes27
C:\Python27_32\lib\site-packages\matplotlib\backends\backend_qt.py:11: MatplotlibDeprecationWarning: QT3-based backends are deprecated and will be removed after the v1.2.x release. Use the equivalent QT4 backend instead.
  mplDeprecation)
17446 INFO: Hidden import 'encodings' has been found otherwise
17446 INFO: Looking for run-time hooks
17448 INFO: Analyzing rthook C:\Users\<user>\Dropbox\pyinstaller-2.0\support/rthooks/pyi_rth_Tkinter.py
17572 INFO: Analyzing rthook C:\Users\<user>\Dropbox\pyinstaller-2.0\support/rthooks/pyi_rth_mpldata.py
17697 INFO: Analyzing rthook C:\Users\<user>\Dropbox\pyinstaller-2.0\support/rthooks/pyi_rth_encodings.py
17819 INFO: Analyzing rthook C:\Users\<user>\Dropbox\pyinstaller-2.0\support/rthooks/pyi_rth_versioneddll.py
17955 INFO: Analyzing rthook C:\Users\<user>\Dropbox\pyinstaller-2.0\support/rthooks/pyi_rth_win32comgenpy.py
18098 INFO: Analyzing rthook C:\Users\<user>\Dropbox\pyinstaller-2.0\support/rthooks/pyi_rth_versioneddll.py
19493 INFO: Adding Microsoft.VC90.MFC to dependent assemblies of final executable
19554 INFO: Searching for assembly x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
19555 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86.manifest
19560 INFO: Searching for file mfc90.dll
19561 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfc90.dll
19562 INFO: Searching for file mfc90u.dll
19562 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfc90u.dll
19562 INFO: Searching for file mfcm90.dll
19562 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfcm90.dll
19562 INFO: Searching for file mfcm90u.dll
19562 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b81d038aaf540e86\mfcm90u.dll## Heading ##
20465 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
20723 INFO: C:\Users\<user>\Dropbox\pyinstaller-2.0\hello\build\pyi.win32\hello\out00-Analysis.toc no change!
20749 INFO: checking PYZ
20808 INFO: checking PKG
20809 INFO: building because C:\Users\<user>\Dropbox\pyinstaller-2.0\hello\build\pyi.win32\hello\hello.exe.manifest changed
20810 INFO: building PKG out00-PKG.pkg
20838 INFO: checking EXE
20838 INFO: rebuilding out00-EXE.toc because pkg is more recent
20838 INFO: building EXE from out00-EXE.toc
20844 INFO: Appending archive to EXE C:\Users\<user>\Dropbox\pyinstaller-2.0\hello\build\pyi.win32\hello\hello.exe
20854 INFO: checking COLLECT
WARNING: The output directory "C:\Users\<user>\Dropbox\pyinstaller-2.0\hello\dist\hello" and ALL ITS CONTENTS will
be REMOVED! Continue? (y/n)y
23423 INFO: Removing dir C:\Users\<user>\Dropbox\pyinstaller-2.0\hello\dist\hello
23703 INFO: building COLLECT out00-COLLECT.toc

但是当我尝试运行可执行文件时,我遇到了一个导入错误:

PS C:\Users\<user>\Dropbox\pyinstaller-2.0\hello\dist> .\hello.exe
cannot import name hashtable
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "C:\Users\<user>\Dropbox\pyinstaller-2.0\PyInstaller\loader\iu.py", line 386, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\Users\<user>\Dropbox\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
    exec co in mod.__dict__
  File "C:\Users\<user>\Dropbox\pyinstaller-2.0\hello\build\pyi.win32\hello\out00-PYZ.pyz\pandas", line 6, in <module>
ImportError: cannot import name hashtable

知道如何解决这个问题吗?我在使用 Python 2.7.5 的 Windows 8 上。我尝试使用来自 Gohlke 网站的 Pandas 二进制文件以及使用 pip install (其他一些线程建议 pip install 是解决哈希表错误的方法)。我看到了同样的错误。

作为参考,我可以让 pyinstaller 使用其他不使用 Pandas 的脚本工作。

我还可以让 Pandas 使用 py2exe 编译成可执行文件,但我想要一个可执行文件,并且由于某种原因,py2exe 可执行文件需要永远运行(该简单脚本需要 5 秒以上)。

4

1 回答 1

3

使用 Pyinstaller 的开发版本可以解决这个问题。仍然看到相同的警告,但运行可执行文件不再引发导入错误并打印所需的结果。

于 2013-07-28T01:20:12.960 回答