I made an app for my friends but I can't make executable file. I tried to use pyinstaler and cx_Freeze but it didn't worked. It creates properly an exe file but It doesn't work. When I try to run executable It pops out empty cmd window and disapears without any error.
Im working on python 3.7.4.
There is code that I used to create exe with cx Freeze:
import cx_Freeze
executables = [cx_Freeze.Executable("GenshinHelper.py")]
cx_Freeze.setup(
name="GenshinHelper",
options={"build_exe": {"packages":["pygame",'datetime'],
"include_files":['img1.jpg','img2.jpg']}},
executables = executables
)
Here is one way t do that;
first install pyinstaller;
pip install pyinstaller
then write this command;
pyinstaller --onefile -w your_file.py
--onefile will convert all the files in your project into a single file.
-w: command prompt (console) will not pop-up when you will run this .exe file. If your app is a console app, then remove -w.
This will convert your file into an .exe file and will run on any other computer without python installed.
More info at https://youtu.be/UZX5kH72Yx4.
Related
I was trying to convert my main.py to a exe file
I followed a tutorial on youtube i did it like it said
first open cmd in the folder
then type in pip install pyinstaller
then type in like this pyinstaller --onefile main.py
but it does'nt convert it shows this
While Eyal's solution is correct, there is an easier option. Just run this:
py -m PyInstaller --onefile main.py
It could also be python -m PyInstaller --onefile main.py depending on your system configuration.
This issue is probably caused because pyinstaller is not in the PATH environment variable.
First, find the full path of pyinstaller.exe - it should be in the Scripts directory of your Python installation (probably C:\Users\[USERNAME]\AppData\Local\Programs\Python\[Python_VER]\Scripts). Copy the full path.
Then open a command prompt (as Administrator) and run the command:
setx PATH "%PATH%;PYINSTALLER_PATH"
where PYINSTALLER_PATH is the full path of pyinstaller you have copied.
Then re-launch command prompt and run the command again.
I tried making my python file into an exe using pyinstaller main.py --onefile --noconsole
.I was getting an error when I tried opening the exe from dist so i used --debug=all and it said pyinstaller: error: the following arguments are required: scriptname.
What exactly do i do im not too sure as its my first time.
To convert a python file to exe:
Make sure you have pyinstaller installed and up to date
pip install pyinstaller
in PowerShell type the following:
pyinstaller --onefile -w 'youfilename.py'
The file name should come out as 1.exe
Make sure are in the right directory
If you have more doubts use this link: https://www.geeksforgeeks.org/convert-python-script-to-exe-file/
I tried to convert my python gui application (.py ) to an executable file(.exe) using the pyinstaller module. I ran the following command in the terminal -
pyinstaller.exe --onefile -w sourcecode.py
The process was completed successfully and I got the .exe file(sourcecode.exe) along with the extra folders like pycache and sourcecode. But when I tried to run the .exe file/application by double clicking on it the app didn't start up and gave an error. Please help.
Try adding this --hidden-import to pyinstaller.exe --onefile -w sourcecode.py in case of hidden modules.
You can also try adding --debug to see what the error actually is.
I want to convert my python script to exe without additional files like ddl, pyd..
Is it possible?
Use pyinstaller https://github.com/pyinstaller/pyinstaller
Install it by running pip install pyinstaller in terminal / console
Then run pyinstaller --onefile yourscriptsname.py and it will create you an exe file in the same directory
I have been using Pyinstaller to convert python scripts into executables. It has worked for me just fine in the past. However now when I try to run the executables (both old ones and new ones) I get the error "Cannot open self _____ or archive _____", where the first blank is the path of the executable and the second is the path of an archive that does not exist, ending in ".pkg". I did change the path of the source code, but that should not be preventing new executables I made after the switch from working, and isn't the point of compiling a .py into a .exe mobility?
I am on windows 7, using the cmd window to run the executables (which I'll repeat has worked in the past.) I'm using Python 3.5, and the commmand with which I am building executables is
pyinstaller.py --onefile --clean programName.py
The same happened to me when I:
kept the executable opened on a Windows virtual machine;
in the same time I began to rebuild the executable with Pyinstaller;
then I rerun the executable and got the same message
Once I closed the application and then ran Pyinstaller, the problem dissapered.