How can I “compile” scripts using the Pandas module with pyinstaller?

I am trying to create an executable from a Python script that uses Pandas using pyinstaller 2.0.

I have a very simple test script ('hello.py'):

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

Pyinstaller is working fine, except for a few warnings:

 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 

But when I try to run the executable, I am greeted by an import error:

 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 

Any idea how I can fix this? I am on Windows 8 using Python 2.7.5. I tried using the Pandas binaries from the Gohlke website as well as using pip installation (in another thread it was pointed out that pip install is a way to resolve the hashtable error). I saw the same error.

For reference, I can get pyinstaller to work using other scripts that do not use Pandas.

I can also get Pandas to compile into an executable using py2exe, but I need one executable, and for some reason, the py2exe executable will run forever (> 5 seconds for this simple script).

+4
source share
1 answer

Using the development version of Pyinstaller fixes this problem. They still see the same warnings, but running the executable no longer causes an import error and prints the desired result.

+3
source

Source: https://habr.com/ru/post/1493857/


All Articles