Force virtualenv pip to be used

Peter Otten __peter__ at web.de
Sun Nov 6 08:36:33 EST 2016


Alec Taylor wrote:

> On Sunday, November 6, 2016 at 10:20:53 PM UTC+11, Peter Otten wrote:
>> Chris Angelico wrote:
>> 
>> > On Sun, Nov 6, 2016 at 9:17 PM, Alec Taylor <alec.taylor6 at gmail.com>
>> > wrote:
>> >> Running Ubuntu 16.10 with Python 2.7.12+ (default one) and virtualenv
>> >> 15.0.3 (`sudo -H pip install virtualenv`). What am I doing wrong?
>> >>
>> >>     $ virtualenv a && . "$_"/bin/activate && pip --version
>> > 
>> > I'm pretty sure virtualenv (like venv, about which I'm certain)
>> > creates something that you have to 'source' into your shell, rather
>> > than running in the classic way:
>> > 
>> > source env/bin/activate
>> 
>> I think this is what the
>> 
>> . "$_"/bin/activate
>> 
>> part of Alec's command is supposed to do.
>> 
>> Yes, that's a dot, not grit on Tim's screen ;)
>> 
>> > It needs to alter environment variables in your shell, which can't be
>> > done from a separate program.
> 
> Hmm:
> $ echo $PYTHONPATH
> /usr/local/lib/python2.7/site-packages:/usr/local/lib/python2.7/dist-
packages
> $ pip --version
> pip 9.0.0 from /tmp/a/local/lib/python2.7/site-packages (python 2.7)
> 
> 
> So that worked. Shouldn't PYTHONPATH be set/upserted by the activation of
> the virtualenv?

That would have been my expectation, but I don't feel competent to recommend 
changes in pip. Also, to avoid mixing Python 2 and 3, I tend to use pth 
files to configure non-standard module locations.





More information about the Python-list mailing list