PyInstaller – FileNotFoundError: [Errno 2] No such file or directory

Question:

I’m not too familiar with using PyInstaller but I have been trying to use it to convert my .py files to a single exe. I am using Windows 10 with Python 3.10.5 and PyInstaller 5.2. My files look like the following:

Scripts Folder

       -venv Folder

       -Dependent Files Folder

       -main.py

       -1.py

       -2.py

       -3.py 

       -4.py

I am able to create an exe using ‘pyinstaller –onefile -w main.py’ in the console and move it from dist to the main Scripts folder. Once I launch the exe I get the error FileNotFoundError: [Errno 2] No such file or directory: ‘C:UsersJackAppDataLocalTemp_MEIXXXXXpalettablecolorbrewerdatacolorbrewer_all_schemes.json’. I’ve also tried using auto-py-to-exe and get the same issue.

When I check that directory I don’t see a folder ‘palettable’ in the _MEIXXXXX folder (hence the error), but I’m not sure how to add it to that directory. I do see ‘colorbrewer_all_schemes.json’ in the venv folder within the same _MEIXXXXX folder but the exe can’t find it there. I can’t add it manually cause it is a temp folder and a new _MEIXXXXX folder will be generated each time I launch the exe again. I’ve also made sure the library ‘palettable’ is installed in the virtual environment and in console.

As I say I’m not too familiar with converting .py files to .exe so any help is appreciated. Let me know if you need more information.

Asked By: brj

||

Answers:

I found an answer to my own question. I still don’t know why it couldn’t find the palettable library but I was able to get it working by putting this in the command window:

pyinstaller –collect-data palettable –onefile main.py

This allowed it to I guess collect it manually though I’m still not sure how it wasn’t able to find palettable in the first place since its installed the same way as all the other dependent libraries. Hopefully this helps anyone with a similar issue.

Answered By: brj

hi i had the same problem with dash_daq library that it was solved by your method thank you very much

Answered By: m.zaeim