Question

I want to run a python script on a remote linux machine. The script requires a package networkx. However, I can't install python package on the remote machine, so what can I do?

Was it helpful?

Solution

There are generally four options (more can exist):

Install into user profile

$ pip install --user networkx

This does not require root priviledges and install into user specific directories.

Install into virtualenv

$ virtualenv env
$ cd env
$ source bin/activate
$ pip install networkx

Note, there is no --user option present.

When you need to start the program, you will need to use python from env/bin directory, this will automatically use the virtualenv you have set up before. (no need to call activeate.

Install into local subdirectory

You may put the egg or source code of needed package into local directory and manipulate sys.path to include it, then it would import from there. However, this is not easy and in fact it does the same, what virtualenv offers.

use zc.buildout

zc.buildout tool is alternative solution to virtualenv. You can keep all in one directory tree, run from here. I used to use this solution in past many times, but comparing to virtualenv it is a bit too complex

OTHER TIPS

Use py2exe and cython to convert .py files to .pyc files..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top