What is the simplest way to do a user-local install of a python package?

  • 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?

    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`?)

    it was hypothetically posed :) virtualenv is awesome but it doesn't fit every use case.

  • 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
    

    Update by RafiK

    pip install --user foo
    

    The following answer is provided for historical purposes: It's a little more work if you are using pip to download and install:

    pip install --install-option="--prefix=$HOME/.local" foo
    

    update: pip now supports a --user flag: `pip install --user SomePackage` (link to manual) Using this, everything should work out of the box even on different OSes

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM