Force virtualenv pip to be used

Alec Taylor alec.taylor6 at gmail.com
Mon Nov 7 03:02:50 EST 2016


On Monday, November 7, 2016 at 1:07:12 AM UTC+11, Chris Angelico wrote:
> On Sun, Nov 6, 2016 at 10:19 PM, Peter Otten <__peter__ at web.de> 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 ;)
> 
> Yep, I see that now. Guess my screen's dirty again. Sorry!
> 
> There are a few possibilities still.
> 
> 1) You *are* running all this from /tmp, right? "virtualenv a" creates
> a subdirectory off the current directory, and then you look for
> /tmp/a.
> 
> 2) Is there an esoteric interaction between the bash "&&" and the
> source command?
> 
> 3) virtualenv could behave differently from venv. It's a third-party
> package that works by hacks, compared to the properly-integrated venv
> module.
> 
> Further research is required.
> 
> ChrisA

venv seems to be a Python 3 thing. I'm using Python 2. Will probably experiment with Python 3 also and get cross compatibility, but then I'd still use virtualenv so I get consistent tooling.

And the issue has been found: PYTHONPATH being set caused the problem.



More information about the Python-list mailing list