I am getting a error in converting a .py file to .exe file. The exe file shall be delivered at the build folder but it was not there.
In the explorer, go to the .py file you want to convert to an .exe
Click the path and write cmd
In the terminal that should have popped up, type pyinstaller --onefile (and -w if your program doesn't require the terminal) filename.py
Hit enter and wait for it to convert
The .exe now should be in the dist folder, which is in the same folder your .py file is in
Good luck! :)
Related
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.
I have made a python file and it is a pygame. I want to convert it into a .exe file.
So, I used PyInstaller
I did pyinstaller --one file -w main.py
and it made a .exe file.
However, when I double-click it, it popped up a
Not Running warning
Why does it occur and what should I do to prevent it?
I am trying to add one executable (.exe) file, a .conf file and a .bat file into the binary package created by pyinstaller and then through that binary package i want to call the .bat file that will send some commands to .exe and that exe will pick the configuration file from .conf and do its work.
** Example **
Click on Run button from Python Package.
Python Package runs .bat file inside it.
.bat file calls .exe with arguments
.exe picks config from .conf file and do its work
Before you create the binary through pyinstaller:
Add files (.conf and .bat and .exe) to the bundle using the Analysis call in the .spec file.
When you run the binary created through pyinstaller it unpacks itself at a temporary location in AppData on Windows by default. You should be able to get that path through sys._MEIPASS
In the python script run the .conf, .bat and .exe files preferably using subprocess.
Currently to use Pyinstaller I open a Python command console then go to the location of my .spec file using cd and type pyinstaller Software.spec. It works well but I'd like to automate that and have a .bat file do those operations for me.
I have made small .bat files to execute my programs (see below) and I thought the structure for calling Pyinstaller would be close but I'm groping.
C:\Python\python-3.6.3.amd64\python Software.py
pause
Failed attempts of .bat files to run Pyinstaller include:
C:\Python\python-3.6.3.amd64\python\Scripts\pyinstaller.exe Software.spec
C:\Python\python-3.6.3.amd64\python CALL :pyinstaller Software.spec
Any idea would be welcome.
Solution
We need to execute Pyinstaller.exe with Python like so:
"path\to\python.exe" "path\to\pyinstaller.exe" "path\to\my\Software.spec"
Typically you need to call the path to the script as well, but also always double quote paths to ensure you do not get some whitespace kreeping in. Always call the full extension name of an executable as good measure.
"C:\Python\python-3.6.3.amd64\python.exe" "C:\path\to\Software.py"
You can also start it, but in the same batch window:
start /b "" "C:\Python\python-3.6.3.amd64\python.exe" "C:\path\to\Software.py"
or with pyinstaller.exe example:
"C:\Python\python-3.6.3.amd64\python\Scripts\pyinstaller.exe" "C:\path\to\Software.spec"
A simple drag and drop of any python file will result in a compiled exe file in the dist folder created from executing the pyinstaller script.
#echo off
PATH = "%PATH% + %USERPROFILE%\AppData\local\programs\python\Python38"
:: %1 is the file dropped on the batch file
pyInstaller --windowed --onefile %1
If you change %1 to the filename it will also work. Save the script as Pyinst.bat then drag and drop a python file onto it.
I have a program with python and it has 3 modules .py.
what should i do to create exe format of this program?
i try this with pyinstaller but thats create exe for my main .py and other .py
modules not contains in it!
Install pyinstaller:
Go to command prompt and type pip install pyinstaller.
Create .exe:
If you want to create a .exe from a .py you need to open your command prompt under the correct directory of the file and type:
pyinstaller —-onefile filename // e.g hello.py as the filename
If it has any basic graphics, type the following in command prompt
pyinstaller —-onefile -w then your file name
This should all work.
If it does not I recommend that you watch this video.