Execute Python scripts without installing Python. Usefull for machines that have no internet connection (air gap environment) to install Python and dependency libraries. The single file executable can be created for Windows, Linux, Unix, and MacOS.
- The single file tool utilizes PyInstaller to create a single executable package.
- The exectuable tool will then utilize the Python library "importlib.import_module" to run external Python script.
- This tool demonstrates how easy to create a package that executes Python scripts without an installed Python.
- Download and install Python 3.X
- Install Python's Virtual Environment module
pip install virtualenv
- Create a python virtual environment
python -m venv c:\virtualpython\PYTHON3
- Activate the python virtual environment
c:\virtualpython\PYTHON3\Scripts\activate.bat
- Change folder to PyScriptRunner source code path
cd C:\PyScriptRunner
- Install the required modules
pip install -r PyInstaller
- Build the single executable app. The executable file will be placed at dist subfolder.
Pyinstaller main.spec
PyScriptRunner.exe yourscript.py
If your script needs other Python libraries:
- You need to install the Python library in your build environment
- Declare the library import in pyscriptrunner.py
- Build the single executable app again.
Example if your script needs psutil:
- pip install -r psutil
- Add "import psutil" in pyscriptrunner.py
- Pyinstaller main.spec
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Always ensure that the Python scripts are safe to run, as they will be executed as-is.