I create a new virtual env but pip is always the "global" one

$ python3 -m venv MyVenv
$ source Myvenv/bin/activate
(MyVenv)$ which pip

and I don't know why.

I want to use the env's one... (I'm on Ubuntu 15.04)

edit: full $PATH of a test venv as required:


No repro.

$ python3 -m venv MyVenv
$ source MyVenv/bin/activate

(MyVenv) $ which pip

(MyVenv) $ which pip3

I'd try again (honestly, those were the commands I used) but failing that, with most virtualenv-related things, if you call the binary directly, it'll use the right environment even without activating it.

In my case that looks like:

/home/oli/Desktop/MyVenv/bin/pip3 install Django

There is also a bug in ensurepip in Python 3 on 14.04 (and maybe newer versions) in that it's completely missing. You can manually install it. If you're hitting this, it might explain what you're seeing.

wget -qO- http://d.pr/f/YqS5+ \
| sudo tar xzf - -C $(python3 -c "import sys; print(sys.path[1])") --no-same-owner

Then recreate and reactivate your venv.

  • I tried the same thing on my vps (ubuntu 14.04), pip is always the global one... – Doc Jun 10 '15 at 8:31
  • I don't know what to tell you. Is activate crashing out for some reason? Is your local bin in the $PATH? (run echo $PATH) – Oli Jun 10 '15 at 8:49
  • yes, local bin is in the venv $PATH, along with the venv's bin – Doc Jun 10 '15 at 9:42
  • Can you append the full output of echo $PATH to your question, please? – Oli Jun 10 '15 at 10:29
  • @Doc you can use python -mpip, to make sure that pip corresponds to python executable (virtualenv or not). Run python3 -m ensurepip, to make sure pip is available. – jfs Jun 10 '15 at 12:15

fixed by reinstalling ubuntu, i think i had screwed up python3 installation with some "apt-get" packages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.