Python 3 virtualenv and pip

I installed Python 2 and Python 3 both versions parallel on my Mac with brew.

brew install python python3

... and added "export PATH=/usr/local/bin:$PATH" to my ~/.bash_profile

This worked fine so far. The Brew version of Python also comes with pip and setuptools by default. So the installation of virualenv for Python 2 was easy:

pip install virtualenv
virtualenv py2_venv

Now i wanted to create a virtualenv with Python 3:

pyvenv py3_venv
source ./py3_venv/bin/activate
pip-3.3 install django

The problem is that django is not installed into my virtualenv, instead i will be placed in the global site-packages folder.

Can somebody tell my what i am doing wrong?

Update: It works if i create the venv with virtualenv instead of pyvenv:

virtualenv -p "$(which python3)" py3_venv

5 comments · 81% upvoted · other discussions

comments

killerabbit37

You might want to double check which pip you are calling:

which pip

That should tell you if you are using the virtualenv pip or your system's pip.

1nvader [OP]

I am calling system pip. Does pyvenv not install pip when creating a new venv?

killerabbit37

the bin/activate should add it to your path so it calls it first. Easy work around is to call it directly with

/path/to/p3virtenv/bin/pip install django

You can check your path to see how the activate is changing it:

echo $PATH
source p3virtenv/bin/activate
echo $PATH

It should put /path/to/p3virtenv/bin first so that it takes the highest priority.

1nvader [OP]

Thanks

My path variable seems to be correctly modified by the virtualenv. But it looks like pyvenv does not install distribute and pip into the virtualenv.

killerabbit37

Odd... that would be the problem though I haven't run into that before.