How to run without interpreter installed
What if the user doesn't have Python installed...?
Libraries
Create Executeables
Compiler, JIT-compilers, wrappers and such to make python look like a native app.
- PyInstaller
- Nuitka is a Python compiler written in Python
- PyPy is a JIT-compiler as a replacement for CPython with focus on speed.
- fman build system: fbs is the fastest way to create a Python GUI.
- PyOxidizer is a utility for producing binaries that embed Python. (Written in Rust)
Web
- Brython is designed to replace Javascript as the scripting language for the Web.
- PyPy.js (last release 2015 😫)
PyInstaller
To make PyInstaller work well, you need to setup a proper PyInstaller project.
Setup
First you need a virtual environment. Otherwise a lot of unnecessary modules will be included in your build.
This is done with the virtualenv command:
virtualenv venv
Additionaly it's recommended to create an activate-batchfile:
@venv\scripts\activate.bat
Finally install pyinstaller into the new virtualenv, otherwise the non-venv-pyinstaller might be run.
pip install pyinstaller
Now install further libraries you need. You build by activating the virtualenv and start pyinstaller with your script file as a parameter.
pyinstaller myscript.py
Further build options is making one exe file out of all files and the use of a custom icon:
pyinstaller myscript.py --onefile --windowed --icon myicon.ico > build.log
- onefile: Collect everything into one EXE file.
- windowed: Don't show a shell window when starting
- icon: Replace standard icon with custom one
Batchfile
This is the batchfile that creates all necessary data:
@echo off
rem newprj.bat
echo Making dir for %1
md %1
cd %1
echo Creating Virtual Environment
virtualenv venv
echo Setting up Project Files
echo call activate.bat > build.bat
echo pyinstaller %1.py >> build.bat
rem echo pyinstaller %1.py --onefile --icon %1.ico > build.txt
echo # %1.py - v.01 > %1.py
echo @venv\scripts\activate.bat > activate.bat
echo @venv\scripts\deactivate.bat > deactivate.bat
echo Installing Base Libraries
call activate.bat
pip install pyinstaller
You start like this:
newprj myproject