Compiling Python code: Difference between revisions

From PedrosBrainDump
Created page with " pip install pyinstaller pyinstaller --onefile script.py"
 
No edit summary
 
Line 1: Line 1:
Install the pyinstaller with pip
  pip install pyinstaller
  pip install pyinstaller
Use the pyinstaller to compile the binary
pyinstaller --onefile script.py
The binary will be on the dist directory.
Create your Python code:
sh-5.2$ cat main.py
print('Hello, World!')
sh-5.2$ python3 main.py
Hello, World!
Compile your code
sh-5.2$ pyinstaller --onefile main.py


  pyinstaller --onefile script.py
Run the binary
  sh-5.2$ dist/main
Hello, World!

Latest revision as of 21:52, 12 October 2024

Install the pyinstaller with pip

pip install pyinstaller

Use the pyinstaller to compile the binary

pyinstaller --onefile script.py

The binary will be on the dist directory.

Create your Python code:

sh-5.2$ cat main.py 
print('Hello, World!')
sh-5.2$ python3 main.py 
Hello, World!

Compile your code

sh-5.2$ pyinstaller --onefile main.py 

Run the binary

sh-5.2$ dist/main 
Hello, World!