2

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:

  1. 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.
  2. Build from onedir instead of onefile pyinstaller --onedir myscript.py
  3. Change hiddenimports in spec file to hiddenimports = ['pandas._libs.tslibs.timedeltas', etc.] and also hiddenimports = ['pandas']
  4. Put import pandas at the top in .py
  5. 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 raised AttributeError: 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?

Cat Mai
  • 430
  • 4
  • 8
  • 1
    Does this answer your question? https://stackoverflow.com/questions/29109324/pyinstaller-and-pandas – Vikramaditya Gaonkar Apr 20 '20 at 23:12
  • @VikramadityaGaonkar Interesting, now it raises ``ImportError: Unable to import required dependencies: numpy: No module named 'numpy'`` without me ever importing numpy in my script. I had numpy installed in both Anaconda and Python lib. Not sure why – Cat Mai Apr 20 '20 at 23:30

1 Answers1

1

I finally fixed it by reinstalling pandas and numpy. I didn't think of this because I reinstalled pandas during the process multiple times. Anyway if anyone was having the same problem and need a last resort:

pip uninstall pandas -y pip uninstall numpy -y pip install pandas pip install numpy

Edit: After this I realize that the way I installed/hooked up Anaconda was messy so I reinstalled Anaconda and pyinstaller was so much easier to work with. To use pyinstaller with Anaconda instead of default python after reinstalling Anaconda, conda install -c conda-forge pyinstaller

Cat Mai
  • 430
  • 4
  • 8