I've been grappling with PyInstaller and not sure how to fix ModuleNotFound (specifically pandas
). My .py program is a simple onefile script that imports only (Anaconda-)native packages (eg tkinter, pandas, os) and it worked in the IDE. I know that PyInstaller only import top-level packages so I'll list my approaches so far:
- Run in virtual env to downgrade Python 3.8 to 3.7.5. I heard people had problem with PyInstaller with Python 3.8. Also updated latest version of PyInstaller. Also tried without env.
- Build from onedir instead of onefile
pyinstaller --onedir myscript.py
- Change
hiddenimports
in spec file tohiddenimports = ['pandas._libs.tslibs.timedeltas', etc.]
and alsohiddenimports = ['pandas']
- Put
import pandas
at the top in .py - Follow this one: How can I add a Python site-package folder (that's not being included) to a PyInstaller spec file? but fix my path file to
C:\\Users\\username\\Anaconda\\lib
since this was in Anaconda interpreter. Then it raisedAttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long'
and I tried to fixed it to no avail
None of that has worked out. Is there a better way to go about building executable in Python or is there a fix for this?