1

I am writing a python3 app, that I would like to run on different computers.

The main obstacle I found, is the fact that Windows and OSX does use some API differently, but I can find out on which OS I am running, and handle these cases.

Although one issue came up, as being problematic; which is the fact that to use my app, I need to install on every machine I want it to run, all the dependency packages. Manual install may work, but I would like to achieve a more self-contained approach.

I did look into pyinstall, but it didn't work in my case, since I get missing dependency when I run the application (especially if I use PyQt5 for the UI). Then I discover pipenv; which from my understanding, create a virtualenv and install the required dependency, by just passing the 2 files created when I create my project and integrate it with pipenv; although it is not "self-contained from my understanding. Also virtualenv still has to be installed on the machine, or pipenv won't work.

What is the common python way to generate something that is distributed to other machines, while minimizing and self-containing everything to the max? Thanks

  • You can convert your python file to .exe for windows: https://stackoverflow.com/questions/41570359/how-can-i-convert-a-py-to-exe-for-python Same for MacOS and linux. – Gabriel Ben Compte Jun 25 '18 at 17:39
  • There are two basic ways you could do this: (1) create standalone installer packages for each platform (whether with something cross-platform like pyInstaller, or with separate tools like py2app and py2exe), or (2) create a pip-installable package and upload it to a local repo (assuming this isn't something you want to publish publicly) and let pip pull in the dependencies. Either one should work, but neither one is quite flip-a-switch-and-it-works, so you'll need to read up on the options. – abarnert Jun 25 '18 at 17:44
  • 1
    This is exactly what Docker is for; You create your Docker image with all dependencies and application code bundled into one deployable/runnable artefact. Of course this will require Docker to be installed, but it's only that one requirement as opposed to Python and virtualenv – Keenan Lawrence Jun 25 '18 at 18:30
  • I'll second Keenan's suggestion of Docker. As long as it's installed on both machines, it allows your code to run agnostic of the host OS – C.Nivs Jun 25 '18 at 20:38
  • Thanks for the replies. Is Docker able to access the local machine resources? For example if my application need to use say Blender, or another application that live on the machine on which I run the docker container; or if I need files located on that machine, or if I need to save files on that machine? –  Jun 26 '18 at 05:52
  • I did try to deploy using pyinstaller but when using in conjunction with many dependencies (like numpy, tensorflow, pandas, QT5, just to mention few), I would end up with all sorts of errors, due to missing references. I did spend 3 days troubleshooting the code, and was not able to find out why the application was not even created, since it would trip as soon as the references were parsed. I will try with py2app or py2exe; maybe they are more lenient on newbies. Mostly this won't be widely distributed; jsut for internal network automation and metrics calculation. –  Jun 26 '18 at 05:56

0 Answers0