Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jabbalaci/PythonEXE
How to create an executable file from a Python script?
https://github.com/jabbalaci/PythonEXE
exe pipenv pyinstaller python python3 virtual-environment
Last synced: 2 months ago
JSON representation
How to create an executable file from a Python script?
- Host: GitHub
- URL: https://github.com/jabbalaci/PythonEXE
- Owner: jabbalaci
- License: mit
- Created: 2019-02-09T21:55:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-25T16:12:09.000Z (about 1 year ago)
- Last Synced: 2024-07-18T03:44:36.312Z (3 months ago)
- Topics: exe, pipenv, pyinstaller, python, python3, virtual-environment
- Language: Python
- Size: 329 KB
- Stars: 280
- Watchers: 20
- Forks: 29
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Python EXE Maker
================This little project shows you how to build an executable file
of your Python code.Here, `hello.py` is the main file. It uses a module (`helper.py`),
it imports the `os` module from the stdlib, and it even uses
a 3rd-party library (`requests`).With PyInstaller, you can easily create a single executable file from
this project.$ pyinstaller --onefile hello.py
Under Windows you might have a problem with this. If the `.exe` complains that
a DLL is missing, then try this variation:$ pyinstaller --onefile --noupx hello.py
You'll find the exe in the `dist/` folder.
Why would you need an EXE?
--------------------------EXE is a file extension for an executable file format. It makes distributing your
program much easier. The exe produced by PyInstaller is standalone.
It means that it's enough to give this exe to your friend and (s)he can run it right away.
There is no need to install Python on his/her machine, no need to create a virtual environment, etc.
Under Windows you can simply start an exe with a double click.Of course, if your friend uses Windows (Linux), then create the exe under
Windows (Linux).Will my EXE run faster?
-----------------------**No.** PyInstaller simply creates a bundle that contains everything: your code,
the necessary modules / packages, the virtual environment, the Python interpreter, etc.
When you launch the EXE, it is extracted to your temp folder (under Linux
it's the `/tmp` folder), and your application is started from there. So the
runtime will be approximately the same.For a demo, check out my simple Fibonacci implementation in the folder `speed_test`.
pynt
----[pynt](https://github.com/rags/pynt) is a minimalistic build tool. If you installed everything
with poetry (`poetry install`), then you can also create the executable with the following commands:$ pynt exe
or (using pyinstaller's `--noupx` switch)
$ pynt exe2
Video
-----Click on the image below to open a YouTube video that shows you everything step-by-step:
Changes since the video was made:
* The project was updated for Python 3.8 and PyInstaller 4.0.
* In the video I talk about pipenv, but the project was updated
to use [poetry](https://python-poetry.org/). I tried both pipenv and poetry and [I prefer
poetry](https://pythonadventures.wordpress.com/2019/11/02/moving-from-pipenv-to-poetry/).Links / News / Related Work
---------------------------* This project of mine got included in [PyCoder's Weekly -- Issue #355](https://pycoders.com/issues/355)
under the title "PythonEXE: How to Create an Executable File From a Python Script?"
* Reddit discussion: [here](https://old.reddit.com/r/learnpython/comments/aoxoki/i_made_a_sample_project_to_demonstrate_how_to/).
* [Using PyInstaller to Easily Distribute Python Applications](https://realpython.com/pyinstaller-python/),
a blog post on the same topic
* [PyUpdater](https://github.com/JMSwag/PyUpdater), a pyinstaller auto-update framework