This question already has answers here:
Create a single executable from a Python project [closed]
(3 answers)
Closed 1 year ago.
Hi everyone I want to convert my python file to installer(windows installer) not executable. I already make it executable through py2exe. How can I make an Installer of it. Is it possible.
Pyinstaller is a good option to convert python scripts to an windows executable.
You can install it in cmd.exe as any user and run pip install pyinstaller or pip install --pre pyinstaller.
you can then run it using pyinstaller. (sorry that i can't supply a automated script i wrote after a system restore. I'll write it again soon using pyqt5)
syntax
--onefile - puts the program and it's files into a exe.
--onedir - put your program into a directory (folder) (faster than --onefile as it does not need to extract files)
-c - create a console app.
-w - create an app without the console.
-i "[Path to .ico or exe with icon. e.g C:\Files\CODE\Icon.ico]" - set an icon for your app instead of the default snake-on-a-floppy-disk icon.
you can read the rest here.
You can then get inno setup and create an offline installer.
[sorry, could not be bothered to type it again]
i posted it on https://stackoverflow.com/posts/61597594
Related
This question already has answers here:
How to convert a pyw file to exe?
(2 answers)
Closed 1 year ago.
I made a application that has to can run in background, so I made a script.pyw but I don't know how to make a executable that can do it .
can you please help me ?
You can use pyinstaller to do so. First, install pyinstaller:
$ pip install pyinstaller
Then, run pyinstaller, passing the file to convert
$ pyinstaller script.pyw --onefile --windowed
This question already has answers here:
Create a directly-executable cross-platform GUI app using Python
(13 answers)
Closed 2 years ago.
I made a cool little project for my friend, basically a timer using tkinter, but I am confused on how to let them access this project without having vscode or pycharm. Is it possible for them to just see the Tkinter window or something like that? Is there an application for this? Sorry if this is a stupid question.
You can just built an .exe (Application) of your project. Then just share the application file and anyone can use the application through .exe. You can use pyinstaller to convert your python code to exe.
pip install pyinstaller
then cd to the project folder then run the following command
pyinstaller --onefile YourFileName.py
if you want to make exe without console showing up then use this command
pyinstaller --onefile YourFileName.py --noconsole
I would like to convert a python code with command line argument into windows executable using pyInstaller. I run my python program as follows
python myPython 1
Firstly i wonder that you don't get articles related to to this in your Google search.
First Install pyinstaller by running this command
pip install pyinstaller
For Additional Help
https://pyinstaller.readthedocs.io/en/stable/installation.html
Open command prompt, Now navigate to the directory in which your python file (using the cd command ) is located then enter the code
pyinstaller --onefile .py
This will create a standalone executable file (That i expect you are asking). Below is the link to a stackoverflow question you missed to read. Edit : in the same directory a folder name dist will get created which have your single executable.
How can I convert a .py to .exe for Python?
I have a Python project that I want to convert into an executable. I have installed Pyinstaller. I only know how to convert one single script into .exe, but I have multiple packages with multiple python scripts.
The command line I used with success is:
pyinstaller --noupx --onefile --add-data="cprofiles.ui;." cprofiles_lmfit.py
pyinstaller manages relatively well the multiple '.py' files that you import, no need to cite them. Under the 'add-data' option, you list the non-py files and in my example, the 'cprofiles_lmfit.py' file is the one containing the main.
But as indicated here need help to compile python with pyinstaller (and in few other posts), I am a beginner with pyinstaller. I was never able to use the 'theano' module and I did not optimize. I still have to test the suggestions in the answer.
Converting the main script into .exe should solve the problem, use -onefile to convert it to one exe and rest of the .py files should be included.
1) Open the command prompt
2) Install pyinstaller
Pip install pyinstaller
3) Test your python script first just to check python script should work with normal
.py extension. Saurabh is the name of python file
python saurabh.py
4) Convert the python into executable file
pyinstaller --onefile Saurabh.py
Notice we have passed “–onefile” as a argument which tell pyinstaller to create only one file
5) Go to directory and navigate to the dist folder.
Prerequisite : Install PyQt5 to avoid error.
pip install PyQt5
This question already has answers here:
Create a single executable from a Python project [closed]
(3 answers)
Closed 8 years ago.
Writing some project on Python via PyCharm.
I want to get an exe file from it.
I've tried to "Save as->XXX.exe" - but ,when i'm trying to execute it there is an error "file is not supported with such kind of OS"
p.s.
i've got win7 x64,it doesn't work on x32 too.
You cannot directly save a Python file as an exe and expect it to work -- the computer cannot automatically understand whatever code you happened to type in a text file. Instead, you need to use another program to transform your Python code into an exe.
I recommend using a program like Pyinstaller. It essentially takes the Python interpreter and bundles it with your script to turn it into a standalone exe that can be run on arbitrary computers that don't have Python installed (typically Windows computers, since Linux tends to come pre-installed with Python).
To install it, you can either download it from the linked website or use the command:
pip install pyinstaller
...from the command line. Then, for the most part, you simply navigate to the folder containing your source code via the command line and run:
pyinstaller myscript.py
You can find more information about how to use Pyinstaller and customize the build process via the documentation.
You don't necessarily have to use Pyinstaller, though. Here's a comparison of different programs that can be used to turn your Python code into an executable.