0

Say you have a project, and you want to export it so that you can run it on another machine that:

  1. You don't have root access on
  2. You cannot assume any python packages to be installed other than python itself (not even pip)

Is there a way to export the project, even if it is just a simple script, with everything that it imports, and then everything that the imports need etc.

For example, my project uses a library called python-telegram-bot. It has a list of requirements, and I have tried running pip -r requirements.txt --target myapp to install the requirements into the app's folder, but this is not recursive. For example, requests is not in the library, yet it is needed by the app. And if I manually add requests, there are things that requests needs that aren't part of that.

Is there a way to collect every last bit of requirements into a single folder so that my script functions on an entirely vanilla installation of python?

  • https://stackoverflow.com/q/5458048/7976758, https://stackoverflow.com/search?q=%5Bpython%5D+standalone+script – phd May 11 '20 at 00:30
  • https://stackoverflow.com/a/14447068/7976758, https://stackoverflow.com/search?q=%5Bpip%5D+offline+installation – phd May 11 '20 at 00:31

1 Answers1

0

Pyinstaller creates an executable and you can either roll all dependencies into 1 file (makes it a bit slow to load though) or create a folder with all the packages, modules, imports etc. your script will need to run on any machine. You can Google the docs for pyinstaller, it's all pretty well covered.

Hope that helps, Kuda

Kuda_
  • 3
  • 3
  • The problem with PyInstaller is that the source and the target hosts must be of the same architecture (processor, OS, bitness). You cannot create script on Linux and run it on Windows. You cannot create script on 64-bit OS and run it on 32-bit OS. – phd May 11 '20 at 00:33