Appearance
How can I make a Python script standalone executable to run without ANY dependency?
One way to make a Python script standalone executable is by using the package pyinstaller. First, install it via pip:
bash
pip install pyinstallerYou can then create a standalone executable of your script by running the following command in your command prompt or terminal:
Create a standalone executable of your Python script
bash
pyinstaller --onefile script.pyThis will create a standalone executable of your script named script in the dist folder, which can run without requiring Python or other dependencies to be installed on the target machine.
You can also specify an icon and version information using the --icon and --version-file options respectively. Note that --version-file requires a text file containing the version details.
Create a standalone executable of your Python script, specifying the icon and version file
bash
pyinstaller --onefile --icon=icon.ico --version-file=version.txt script.pyIt is important to note that PyInstaller supports Windows, macOS, and Linux. Executables are platform-specific, meaning a Windows executable will not run on Linux or macOS. If you need to distribute for multiple platforms, you must build the executable on each target operating system. For alternative packaging tools, cx_Freeze works across all major platforms, py2app is designed for macOS, and py2exe is for Windows.