1

I've made a python script that depends of numpy, cv2 and some other modules to run and need to run it on a Linux server where I'm not allowed to install anything. Is there a way to join all that stuff into a single executable that runs without installing anything?

Stefan Zobel
  • 3,182
  • 7
  • 28
  • 38
MickJaggerr
  • 123
  • 1
  • 2
  • 8
  • 1
    That depends. Does the Linux server have Python and pip? Can you create a [virtualenv](https://virtualenv.pypa.io/en/table/)? Else look at https://stackoverflow.com/questions/5458048/how-to-make-a-python-script-standalone-executable-to-run-without-any-dependency and https://stackoverflow.com/questions/4556424/how-to-make-my-python-script-easy-portable-or-how-to-compile-into-binary-with-a – Jedi Jul 06 '17 at 03:53
  • @Jedi It has python installed, pip I believe it doesn't, I'm not allowed to create a virtualenv. – MickJaggerr Jul 06 '17 at 03:58
  • You can try to use the method described in https://stackoverflow.com/questions/12332975/installing-python-module-within-code – Mia Jul 06 '17 at 03:59

2 Answers2

2

It sounds like you're looking for PyInstaller, which bundles all the modules your script depends on into a single program. It even includes Python itself. There are a few alternatives, some of which are listed on this page.

Arthur Tacca
  • 8,833
  • 2
  • 31
  • 49
1

You could create a standalone executable using Nuitka. Assuming you have all required packages on your development machine you can run

nuitka --python-version=2.7 --standalone foobar

Just make sure you run it with the standalone flag and correct python version.

Hevlastka
  • 1,878
  • 2
  • 18
  • 29