Reputation: 2027
How can I install (on Linux) a plain Python distribution to e.g. /opt/myPythonProject/python
? When I afterwards install packages (e.g. pip
) all packages should go in /opt/myPythonProject
. It should simply ignore system python and it's packages.
My ultimate goal is to place my own code in /opt/myPythonProject/mycode
, then zip op the entire project root directory, to deploy it on customer machine. Does this in general work (assuming my own arch/OS/etc. is the same).
So the bigger question is: can I deliver python/packages/my own code in 1 big zip? If yes, what do I need to take into account?
If not: what is the easiest solution to distribute a Python application together with the runtimes/packages and to get this deployed as application user (non root).
Upvotes: 1
Views: 57
Reputation: 3467
I use
Upvotes: 0
Reputation: 86
I've had a similar issue recently with how to distribute my Python program as a stand alone. I used Pyinstaller (http://www.pyinstaller.org/).
You can include other data files such as exes or images by adding their paths to the generated spec file. The documentation is pretty good at explaining it.
Upvotes: 1
Reputation: 1281
Use python virtual environment. Follow the below commands.
pip install virtualenv
virtualenv <my-new-directory>
source <my-new-directory>/bin/activate
pip install <my-package-name>
By doing so all your packages gets installed in the folder:
<my-new-directory>/lib/python2.7/site-packages/
Upvotes: 3