2
votes

So I heard about the proper way to install packages into python by creating a new virtual environment for every project. Being on a mac (10.8) I have installed python3 using Homebrew, then I installed pip and virtualenv on this copy.

Now here comes the problem: I create a new virtualenv, and activate it using:

virtualenv testing
source testing/bin/activate

When I type

which python
/Users/mik/Desktop/testing/bin/python

But typing

which pip
/usr/local/bin/pip

(learned of this when trying to install a package in the virtual environment, and it installed in the system wide installation in /usr/local/)

Inside the folder testing there is no file referring to pip

Extra Question: How does pip know which python to install the files to, for example pip list (which I believe refers to python 2.7) outputs the names of packages installed on python 3.3

1
How did you install pip and virtualenv? - mmmmmm
pip using easy_install and virtualenv using pip - Michal
/usr/bin/easy_install - Michal

1 Answers

1
votes

I'll start with the last question as it explains what is happening.

The commands pip and easy_install are python scripts which are made executable on the filesystem. The python they use is the python that the first line tells to run the script. e.g. in /usr/bin/easy_install it is #!/usr/bin/python This will be Apple's python. So easy_install will install the 2.7 version of pip and virtualenv and will ignore your python3.3 setup.

The way to instal into python 3 is to install the 3.3 version of pip and virtualenv, the easiest way would be to install the Homebrew package for them. I think it is easier and less confusing to use just one package manager (Homebrew here) and not two (i.e. Homebrew and python).

You can also install easy_install directly. The way to do this is install the distribute package using python3.3 explicitly.

Python 3.4 will make this much easier as pip will always be available