Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ways to Convert Python Scripts to .Exe Files
- Note: Install Python from https://www.python.org/downloads/windows/
- Method 1: Using PyInstaller
- Step 1: Install PyInstaller
- $ pip install pyinstaller
- Step 2: Navigate to your script’s directory
- $ cd path\to\your\script
- Step 3: Run PyInstaller
- $ pyinstaller --onefile your_script.py
- Step 4: Locate the executable
- $ path\to\your\script\dist\your_script.exe
- Method 2: Using Auto PY to EXE
- Step 1: Install Auto PY to EXE
- $ pip install auto-py-to-exe
- Step 2: Run Auto PY to EXE
- $ auto-py-to-exe
- Step 3: Configure the settings
- - The Auto PY to EXE GUI will open. In the GUI, you’ll see various options and settings.
- - Click on the Browse button and select your Python script file.
- - Adjust other settings as needed, such as adding additional files or modules, selecting an output directory, and setting other options based on your requirements.
- Step 4: Select the Compilation Mode
- - Choose the compilation mode based on whether you want a single executable file or a folder with the executable and supporting files.
- Step 5: Click “Convert .py to .exe
- Step 6: Find the output
- - Once the conversion is complete, you will find the generated .exe file in the specified output directory.
- Method 3: Using cx_Freeze
- Step 1: Install cx_Freeze
- $ pip install cx_Freeze
- Step 2: Create a setup script
- - Create a setup script (e.g., `setup.py`)
- from cx_Freeze import setup, Executable
- setup(
- name="YourAppName",
- version="1.0",
- description="Your application description",
- executables=[Executable("your_script.py")],
- )
- Step 3: Run the setup script
- $ python setup.py build
- Step 4: Locate the executable
- After running the `build` command, you can find the executable in the `build` directory.
- Source here https://www.analyticsvidhya.com/blog/2024/01/ways-to-convert-python-scripts-to-exe-files/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement