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
Related
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.
I have created a functional python (Python 3.10.4) script that uses Pybluez (version 0.30) to connect to an ESP32. Now I want to use PyInstaller to create a standalone executable application from said script, but I keep running into the following error when executing the command:
pyinstaller scriptname.py
Error:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\X\Python3\lib\site-packages\pybluez-0.30-py3.10-win-amd64.egg\bluetooth\widcomm.py'
In the Python3\lib\site-packages directory, there is a pybluez-0.30-py3.10-win-amd64.egg file, but it contains no sub folders (bluetooth\widcomm.py).
Any help regarding this error would be much appreciated. Let me know if any additional information is required.
Thank You
Try to reinstall Pybluez and use a stable version, e.g. pybluez==0.23, or add widcomm.py manually https://github.com/pybluez/pybluez/blob/master/bluetooth/widcomm.py.
I managed to solve the mentioned problem, and here is how.
An .egg file is basically like a zip file that contains sub folders and files. I had to download a software called ALZip (https://alzip.en.softonic.com/) to view the contents of the .egg file, which showed that the bluetooth/widcomm.py was in fact present in the .egg file.
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\X\Python3\lib\site-packages\pybluez-0.30-py3.10-win-amd64.egg\bluetooth\widcomm.py'
had an issue with the name of the pybluez-0.30-py3.10-win-amd64.egg file so I solved it by Extracting the .egg file to a new folder, and renaming the folder to "pybluez-0.30-py3.10-win-amd64.egg" (yes the .egg should be part of the name as well)
These steps managed to solve the error and I was able to create an exe from my Python Script using pyinstaller. (pyinstaller scriptname.py)
I have used several tools (pyinstaller, cx_Freeze, py2exe) to convert my .py file to .exe file. But with each one of these, the resultant .exe file closes as soon as it runs. Here is a screenshot of the exe file created form pyinstaller.
I have looked at several answers on SO and other platforms but haven't been able to find a solution. Any help would be greatly appreciated.
My apologies for not being able to type these traccebacks out here as I had to take a quick screenshot as the window closed in a second.
The .py file runs fine on its own; there's no issue with the code.
I had this problem about a year ago with pyinstaller and this 2 methods helped me:
Adding import pkg_resources.py2_warn to my script
Using --onedir instead of --onefile
You can also do it using cmd:
pip install pyinstaller
cd followed by the location where your Python script is stored
so an example is:
cd C:\Users\Ron\Desktop\MyPython
then:
pyinstaller --onefile pythonScriptName.py
instead of pythonscriptname.py, put in your python file name.
When you do this there should be a new file called dist in your directory. Wait for a few mins and there should be an .exe file in there.
Here's a temporay solution: I removed all imports related to the googleapiclient for google docs. The .py file gets compiled properly after that.
More Context: There seems to be some issue in this particular library library that causes issues. I have tested the given solutions, they don't seem to work for me. I'll update this answer if I find a "permanent" solution.
python setup.py install
the second line is what I get when I try to run the code in terminal
python: can't open file 'setup.py': [Errno 2] No such file or directory
And if anyone can help setup the module folium in python, that will be great. It's why am going so much trouble. I have tried pip, conda. It works in pycharm, but I want the module to work alone when I open idle by itself.
You are executing command from a different path. It has 2 solution.
You move to that directory where the file setup.py exists and run the script.
Provide the complete path in command like
python c:\temp\setup.py install
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.