CodyKochmann
4/7/2017 - 6:29 PM

For those who are sick of trying to make a standalone python script that is statically compiled and doesn't require python to be installed,

For those who are sick of trying to make a standalone python script that is statically compiled and doesn't require python to be installed, here's how I did it in bash.

#!/bin/bash
# compiles python files given as arguments

function compile-python () {
  for i in "$@"
  do
    pyinstaller --onefile "${i}" && exit 0 || \
    python -m PyInstaller --distpath ./ --onefile "${i}"
  done
}

For those who are sick of trying to make a standalone python script that is statically compiled and doesn't require python to be installed, here's how I did it in bash.

install pyinstaller via pip

pip install --user pyinstaller

run pyinstaller on whatever script youre trying to compile

pyinstaller --distpath ./ --onefile test.py

if the system is complaining that it couldnt find a command called pyinstaller use this instead:

python -m PyInstaller --distpath ./ --onefile test.py

test the compiled output

./test