I have written a simple python script that I am now trying to make an exe file. Whenever I try to run the resulting exe, the program fails at import pandas
and I get the following error.
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
Looking at the cmd output, hook-pandas is loaded. So this is not an issue with pyinstaller finding the pandas hook.
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'
I did have to add pandas-hook to Python27\Lib\site-packages\PyInstaller\hooks
myself. See No module named 'pandas._libs.tslibs.timedeltas' in PyInstaller and https://github.com/lneuhaus/pyinstaller/commit/017b247064f9bd51a620cfb2172c05d63fc75133. Could that be a problem?
Earlier I also tried altering the spec file based on this question, PyInstaller and Pandas, with no luck.
Using:
python 2.7
pyinstaller 3.3.1
pandas 0.22.0.
If anyone knows why pyinstaller can't use a loaded hook or has any ideas as to what to try next, I would really appreciate it.