1

This used to work, but now both give the same result:

$ python -c 'from pip import __file__ as pip_loc; print pip_loc,'
/usr/local/lib/python2.7/dist-packages/pip/__init__.pyc
$ /tmp/.venv/bin/python -c 'from pip import __file__ as pip_loc; print pip_loc,'
/usr/local/lib/python2.7/dist-packages/pip/__init__.pyc

How do I get the /tmp/.venv path?

A T
  • 13,008
  • 21
  • 97
  • 158
  • BTW: This one is just for `virtualenvwrapper`, `$VIRTUAL_ENV` is not defined with 'vanilla' `virtualenv`: http://stackoverflow.com/q/22003769. – A T Nov 02 '16 at 00:42

2 Answers2

1

Thanks to nedbat on IRC:

$ python -c 'from sys import executable; print executable,'
/usr/bin/python
$ /tmp/.venv/bin/python -c 'from sys import executable; print executable,'
/tmp/.venv/bin/python

EDIT: Actually what I really wanted was get_python_lib of:

from distutils.sysconfig import get_python_lib
A T
  • 13,008
  • 21
  • 97
  • 158
0

Activate the virtualenv before importing pip.

hvwaldow
  • 1,296
  • 1
  • 11
  • 13
  • That wouldn't work. To humour you: `/tmp$ . /tmp/.venv/bin/activate (.venv) /tmp$ python -c 'from pip import __file__ as pip_loc; print pip_loc,' /usr/local/lib/python2.7/dist-packages/pip/__init__.pyc` – A T Nov 02 '16 at 01:11
  • Beats me. I can't reproduce that, second line from your initial question gives the venv - path here. – hvwaldow Nov 02 '16 at 01:19
  • What version are you running? - Because this used to work for me also. - I'm running `Python 2.7.12+` – A T Nov 02 '16 at 01:22
  • same version here. – hvwaldow Nov 02 '16 at 01:27