Difference between revisions of "Convert .Py to .exe"

From rbachwiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<h2> Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller</h2>
<h2> Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller</h2>


'''Using PyInstaller (Command Line):'''
'''Using PyInstaller (Command Line):''' <br />
'''Install PyInstaller: Open your command prompt or terminal and execute:'''
'''Install PyInstaller: Open your command prompt or terminal and execute:'''
pip install pyinstaller
* Navigate to your script's directory: Use the cd command to change the directory to where your Python script is located. For example
cd C:\Users\YourUser\Documents\PythonProjects
* Run PyInstaller: Execute the following command, replacing your_script_name.py with the actual name of your Python file:
pyinstaller your_script_name.py
*To create a single executable file (instead of a directory with dependencies), add the --onefile flag:
pyinstaller --onefile your_script_name.py
*pyinstaller --onefile your_script_name.py

Latest revision as of 16:50, 2 December 2025

Converting a Python script (.py) to an executable (.exe) file for Windows can be achieved using tools like PyInstaller

Using PyInstaller (Command Line):
Install PyInstaller: Open your command prompt or terminal and execute:

pip install pyinstaller
  • Navigate to your script's directory: Use the cd command to change the directory to where your Python script is located. For example
cd C:\Users\YourUser\Documents\PythonProjects
  • Run PyInstaller: Execute the following command, replacing your_script_name.py with the actual name of your Python file:
pyinstaller your_script_name.py
  • To create a single executable file (instead of a directory with dependencies), add the --onefile flag:
pyinstaller --onefile your_script_name.py
  • pyinstaller --onefile your_script_name.py