Is it possible to pack a python script/application + Python interpreter in a single file that will just run on another machine that does not have Python already installed?
To be more precise:
- I have a python script I made, called 'instrument.py', running fine on my dev machine
- I want to run this script on another clean machine, that does not have Python installed, and doesn't have internet
- preferably would be a "instrument.exe" file that is self contained, and just run on any other clean machine
- could be a different file for each OS, i.e. an "instrument.exe" for windows and another file "instrument" for Linux would be just fine
Is it possible to distribute a Python application as a single executable file? How?
[SOLVED]
# install pip
sudo apt-get update
sudo apt-get install python-pip
# install PyInstaller
pip install pyinstaller
# turn a python script into a standalone executable file
pyinstaller my_python_code.py --onefile --clean
# to run the standalone executable file
./dist/my_python_code
On a clean virtual machine with Ubuntu 18.04 LTS, PyInstaller works just fine.
pyinstaller mtx3283.py --onefile --clean
produced a standalone executable, a single file of only 4.2 MB. :-+