4

I am trying to clean up a few things now that I have Mavericks. I used Homebrew to install python 2.7 and 3.3. I also have their respective pips. Now I want to have a sane virtualenv setup.

I see from virtualenv with python2 and python3 via Homebrew that I can specify which version of python a newly-created virtualenv will use. What is the best (i.e., easiest to use/remember) way to make sure that a virtualenv using Python 3.3 uses pip3?

ETA: I've not had to use 3.3 before, so this is my first experience trying to maintain different versions. Sorry if this has an obvious answer.

Community
  • 1
  • 1
verbsintransit
  • 888
  • 3
  • 8
  • 18
  • 2
    Execute in your shell "which python" and you will guess the version. You can name your environments as follows: - – moliware Jan 07 '14 at 19:30
  • I'm not sure I follow. Do you mean to imply that because the Homebrew Python 3.3 install includes pip3, setting up a virtualenv with that install will automatically include its pip3? I wasn't taking that for granted. If so, awesome. – verbsintransit Jan 07 '14 at 19:45
  • 1
    I’m not sure how that comment implies that, but yes, you’re right – pip should be installing to the right virtualenv either way, since it’s installed as part of the virtualenv. – Ry- Jan 07 '14 at 19:53

2 Answers2

6

Credit goes to scythargon for this one (left in a comment to Kristof's answer in this thread) and, since it did exactly what I needed, I figured it deserved its own answer.

When creating a virtualenv with virtualenvwrapper use the -p flag to explicitly associate it with a specific version of Python. In the examples below replace {virtualenv_name} with your intended virtual environment name:

Python 3.3:

$ mkvirtualenv {virtualenv_name} -ppython3.3

Python 3.4:

$ mkvirtualenv {virtualenv_name} -ppython3.4

Python 2.7:

$ mkvirtualenv {virtualenv_name} -ppython2.7
Community
  • 1
  • 1
respondcreate
  • 1,780
  • 1
  • 20
  • 23
1

Have a look at this article: Python Development Environment on Mac OS X Mavericks 10.9. It describes quite clearly how to set up both versions of Python on the same machine using Homebrew and contains some helpful pointers.

In the article, the author appends -py3 to a Python3 virtualenv, as @moliware already suggested.

DocZerø
  • 8,037
  • 11
  • 38
  • 66