1

I installed virtualenv on my new MacBook Pro (first time Mac user) before I did anything else (probably a bad idea). When I create an env it contains /lib/Python2.6 inside of it. Afterward I installed Python2.7, but it still only includes a Python2.6 folder in lib, so I assume something is messed up.

Note: If I go to terminal and type python, I correctly get Python2.7.

I've tried to reinstall virtualenv via:

pip install virtualenv --upgrade

and, also

easy_install virtualenv

Both had the same result. They worked fine with no problems, but I still get no Python2.7 folder in lib on new envs (note: I closed and reopened the terminal each time I upgraded to be safe)...

On a side note, I also tried:

brew install virtualenv

but got the following error:

Error: No available formula for virtualenv
orokusaki
  • 55,146
  • 59
  • 179
  • 257

2 Answers2

4
virtualenv foo_env --python=Python2.7

When you pass the python argument, it sets up the bin and lib for that version (assuming you have that version installed, of course).

orokusaki
  • 55,146
  • 59
  • 179
  • 257
-1

This does not answer your question, but I have found the easiest way to get multiple versions of Python up and running on OS X is to use macports. For major tools like PIP and VirtualEnv, macports tends to have the latest versions and it manages everything fairly well.

Then you can install a PIP specific to each version installed, as well as virtualenv. For more general cases where you don't need virtualenv, but just need to test against different vesions, you can use python_select from macports as well.

Once you have macports can install them with

sudo port install python26 py26-pip py26-virtualenv python_select

EDIT: It seems I'm getting downvoted for this response for advocating the use of MacPorts over Homebrew. The reasoning behind this answer was that I was told specifically not to depend on the version of OS X's python. This is why I have a redundant Macports Python 2.6 install and then all of the tools to complement it. If you feel this answer is poor, please leave a specific comment as to why, and how to improve it.

KyleWpppd
  • 2,010
  • 2
  • 16
  • 16
  • thanks. I've read that macports is being sort of phased out in favor of homebrew. – orokusaki Feb 13 '11 at 22:05
  • Agreed. Macports (and fink) are decidedly outdated. In my opinion homebrew is much more integrated and useful than either of them. – chmullig Feb 13 '11 at 22:11
  • Agreed too. homebrew is great. I've also made a post for easily taking the CMMI route (Configure, Make, Make Install) http://webamused.wordpress.com/2011/01/31/building-64-bit-python-python-org-using-ucs-4-on-mac-os-x-10-6-6-snow-leopard/ – mkelley33 Feb 14 '11 at 01:43
  • Seriously, this just came up again: http://stackoverflow.com/questions/4986896/step-by-step-setting-up-python-with-pip-and-virtualenv and I really am curious as to why MacPorts is not a preferred solution? – KyleWpppd Feb 14 '11 at 02:07