Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

I don't want to deal with virtualenv for a local Python installation, I just want to install a few packages locally without dealing with the PYTHONPATH environment variable, how do I do that?

share|improve this question
    
You say "deal with" as if virtualenv was a hassle. I've found the exact opposite to be true. (Perhaps you want --system-site-packages?) –  Andreas Klöckner Sep 23 '12 at 17:09
    
it was hypothetically posed :) virtualenv is awesome but it doesn't fit every use case. –  Aron Ahmadia Sep 25 '12 at 10:17
add comment

3 Answers

up vote 8 down vote accepted

Python (as of 2.6 and 3.0) now searches in the ~/.local directory for local installs, which do not require administrative privileges to install, so you just need to point your installer to that directory.

If you have already downloaded the package foo and would like to install it manually, type:

cd path/to/foo
python setup.py install --user

If you are using easy_install and would like the package downloaded and installed:

easy_install --prefix=$HOME/.local/ foo

It's a little more work if you are using pip to download and install:

pip install --install-option="--prefix=$HOME/.local" foo
share|improve this answer
add comment

Even though I like Python as a language, distributing Python packages is a mess. I always find people not familiar with Python struggling with it.

Next to the user-local install as outlined by Aron (using --user, or --prefix), another option is EasyBuild (http://hpcugent.github.com/easybuild/). Not only for Python packages, but for any (scientific) software package. Once EasyBuild has support for it, building and installing a software package is basically a single command.

For a list of software packages currently supported, see https://github.com/hpcugent/easybuild/wiki/List-of-supported-software-packages.

Disclaimer: I am a developer of EasyBuild.

share|improve this answer
1  
Kenneth Hoste, please DISCLOSE your affiliation with EasyBuild. –  Deer Hunter Jan 20 '13 at 6:23
1  
Kenneth, welcome to SciComp! Please disclose your affiliation with EasyBuild (or any other projects you are promoting in a role other than as a user). Also, when answering questions, please only submit answers that are directly answering the question at hand. I will be deleting the answers you've submitted that don't directly address their corresponding questions. –  Geoff Oxberry Jan 20 '13 at 7:36
    
OK guys, thanks for the heads up. –  Kenneth Hoste Jan 20 '13 at 8:57
add comment

@Aron: Be sure to add the local site-packages path to the environment variable $PYTHONPATH

share|improve this answer
    
It's automatically included in the site path as of Python 2.6 and Python 3.0 :) –  Aron Ahmadia Aug 4 '12 at 10:11
    
@AronAhmadia not if you use the --prefix option. –  Jens Timmerman Jan 21 '13 at 8:02
    
@JensTimmerman - the site path is where Python looks when it starts for modules to import, any time you are running Python. The prefix option specifies where to install a given package when you are installing a Python package. Two completely separate notions. –  Aron Ahmadia Jan 21 '13 at 13:22
    
@AronAhmadia yes, my point is that when you use easy_install --prefix=/tmp you need to add "/tmp/lib/pythonx.x/site-packages" to your PYTHONPATH variable or it will not be picked up by python. –  Jens Timmerman Jan 22 '13 at 14:50
    
@AronAhmadia pastebin.com/6FCTetCc –  Jens Timmerman Jan 22 '13 at 15:02
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.