bmargulies
bmargulies

Reputation: 100013

virtualenv versus setup.py install --user

I'm using setuptools, and I am running with virtualenv. When I try to install --user, I get problems:

  1. a complaint that .pth files are not supported
  2. it seems to be installing outside the virtualenv

Should I just flush the use of --user since I'm in a virtualenv?

exec ../virtualenv/target/vroot/bin/python setup.py install --user
running install
Checking .pth file support in /Users/benson/.local/lib/python2.7/site-packages/
/Users/benson/x/ws-client-bindings/python/setup/../virtualenv/target/vroot/bin/python -E -c pass
TEST FAILED: /Users/benson/.local/lib/python2.7/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

Upvotes: 4

Views: 645

Answers (2)

davidism
davidism

Reputation: 127190

The user directory is part of Python, not virtualenv. Packages installed to user will look like system packages (they will be available outside a virtualenv). So it is not a solution for isolating package requirements and versions for a specific application.

The standard procedure is to activate a virtualenv and use install without the --user option.

Upvotes: 5

khampson
khampson

Reputation: 15306

Yes, I would recommend dropping that usage pattern and install everything using pip invoked directly from the bin directory of your virtualenv. I find absolute paths when installing/running from a virtualenv is best, since in that case there's never any question as to exactly which one it's using.

You can then keep track (say, in source control) of the requirements files for each of your virtualenvs (via pip freeze > requirements) so they can be created elsewhere quickly.

Upvotes: 2

Related Questions