How to install python modules without root access?

You may have been given an 'instructional account',  which is a school account or shared account that you can ssh into to do work. However, you may also want to run some computationally intensive Numpy, matplotlib, scipy code on that machine. Unfortunately, you cannot install these modules because you am not a system administrator.

How can I do the installation?

With easy_install you can do:

easy_install --prefix=$HOME/local package_name
which will install into $HOME/local/lib/pythonX.Y/site-packages (the 'local' folder is a typical name many people use, but of course you may specify any folder you have permissions to write into).
You will need to manually create $HOME/local/lib/pythonX.Y/site-packages and add it to your PYTHONPATH environment variable (otherwise easy_install will complain -- btw run the command above once to find the correct value for X.Y).
If you are not using easy_install, look for a prefix option, most install scripts let you specify one.

With pip you can use:

pip install --install-option="--prefix=$HOME/local" package_name
or, even better (from comment below), you can rely on the so-called "user site" location (see the PEPfor details) by doing
pip install --user package_name

0 comments

Popular Posts

无觅相关文章插件,迅速提升网站流量