Pyinstaller - FileNotFound error - python

I have created a python script and converted it into a .exe file by using:
Pyinstaller –-onefile RFOutputGraphs.py
It works, however one of the jobs in the scripts is failing, despite it working perfectly when run from Python.
My error is:
FileNotFoundError: [Errno 2] no such file or directory:
'C:\\Users\\Nicholas\\AppData\\Local\\Temp\\_MEI30362\\currency_converter
\\eurofxref-hist.zip'
I am guessing it is not recognising what is probably an unusual module (currencyconverter)
Is there a way of fixing this?
Thank you

You can include the zip file in the .exe created by Pyinstaller using the --add-binary option as:
Pyinstaller --add-binary <path to zip>;currency_converter --onefile RFOutputGraphs.py
This copies the zip file from its location on your PC into the .exe file, and arranges for it to be extracted into the currency_converter folder (the location mentioned in the error message) when the .exe is run. Have a look at Using Pyinstaller.

Related

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

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:\Users\Jack\AppData\Local\Temp\_MEIXXXXX\palettable\colorbrewer\data\colorbrewer_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.
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.

File not found when executing a .exe from PyInstaller

I have a script which contains several libraries, one of which is iapws.
When I create an executable using
pyinstaller --onefile myScript.spec
I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\Miguel\AppData\Local\Temp\_MEI147002\iapws\VERSION
I tried upgrading all my libraries and using hiddenimports=['iapws'] on the spec file
As far as I understand, the problem is that the necessary files are not being extracted into the temp folder when executing the file.
Any workaround for this?
Thank you very much
You need to force pyinstaller to include iapws files, as it seems to have issues generating the appropriate hooks. This worked for me:
pyinstaller "your_script.py" --collect-all iapws
I reviewed command options here which helped:
https://pyinstaller.org/en/stable/usage.html

pyinstaller .exe file doesn't work on another computer

I have used pyinstaller to compile the py file into exe, on my computer it is working well
but when i am trying to download it on another computer it's always giving me error,
FileNotFound: no such file or directory when i compiled the py file i added the python39.dll.
here is the command i used:
pyinstaller --noconfirm --onefile --console --add-binary "C:/Users/Usern/Desktop/dist/python39.dll;." "C:/Users/Usern/Desktop/dist/m.py"
I am trying to create a file with this command:
f1 = open("C:\\Users\\Usern\\AppData\\Local\\Mine\\x.exe", "wb").write(x_req)
again in my computer that .exe file works well as should be but in another computer it does not work.
The program is trying to pull in a file that isnt on the computer. I had the same problem when my program used an image, it had to be in the same directory.

Why Is pyinstaller replacing my file directory?

edit: How To Use --add-data with an entire folder?
Im converting my .py file to .exe using pyinstaller. but when i run it, it gives me this error:
Failed To Execute Script "test.py" due to unhandled exception: Couldn't open "C:\Users\Dani\AppData\Local\Temp_MEI11962\button_start.png" no such file or directory
Failed To Obtain/Convert Traceback!
Therefore My Converted Python File (exe) Was in the same directory As My Image.
My path code is built like this:
from locate import this_dir
path = this_dir()
str(path) + "\\button_start.png"
A possible solution is to use pyinstaller's --add-data argument as shown in the documentation. You can either append this to your command when building the .exe or include that in a pyinstaller.spec file.
Additional information:
When you execute a .exe, that was created with pyinstaller, it will create a temporary folder that is named _MEI<some numbers>, just as you showed above. In there, it expects all the necessary files. Therefor, this is also the place, where it will search for the image, no matter where you put your .exe to or where you execute it. Since this folder is generated temporarily every time you start the .exe, it would not help to simply copy your image there.

Pyinstaller tells me he created the .exe file but I can't find it

Well basically i did this:
pyinstaller --onefile --name=OrdnerErstellen --windowed "filepath"
And it worked out but then I copied the Path where my .exe file should be and my PC couldn't find the file. Does somebody know why?
It also didn't even create the dist folder where all these files are supposed to go...
Im really new to programming and I just wanted to try it out :)
EDIT: PyInstaller did make a compiled .pyc file for the one I wanted, but didn't create the .exe
Simple navigate to the folder where you kept your_script.py file , From there run on console pyinstaller --onefile your_script.py

Categories

Resources