Skip to content

Python Script Runner - Single executable file to run Python scripts without installing Python

License

Notifications You must be signed in to change notification settings

RandySabatin/PyScriptRunner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PyScriptRunner - Python Script Runner

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.

Detail

  1. The single file tool utilizes PyInstaller to create a single executable package.
  2. The exectuable tool will then utilize the Python library "importlib.import_module" to run external Python script.
  3. This tool demonstrates how easy to create a package that executes Python scripts without an installed Python.

Sample How to Create the Tool For Windows

  1. Download and install Python 3.X
  2. Install Python's Virtual Environment module
       pip install virtualenv
  1. Create a python virtual environment
       python -m venv c:\virtualpython\PYTHON3
  1. Activate the python virtual environment
       c:\virtualpython\PYTHON3\Scripts\activate.bat
  1. Change folder to PyScriptRunner source code path
       cd C:\PyScriptRunner
  1. Install the required modules
       pip install -r PyInstaller
  1. Build the single executable app. The executable file will be placed at dist subfolder.
       Pyinstaller main.spec

Sample usage on Windows

       PyScriptRunner.exe yourscript.py

Adding your script's needed Python libraries

If your script needs other Python libraries:

  1. You need to install the Python library in your build environment
  2. Declare the library import in pyscriptrunner.py
  3. Build the single executable app again.

Example if your script needs psutil:

  1. pip install -r psutil
  2. Add "import psutil" in pyscriptrunner.py
  3. Pyinstaller main.spec

Contributing:

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Safety:

Always ensure that the Python scripts are safe to run, as they will be executed as-is.

License:

MIT

About

Python Script Runner - Single executable file to run Python scripts without installing Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages