My Adventures in Coding

September 11, 2011

Python – Upgrading Python with easy_install, pip, and virtualenv on a Mac

Filed under: Mac,Python — Brian @ 1:45 pm
Tags: , ,

For this tutorial I am upgrading from python 2.6 to python 2.7 on my Mac. Every time I have to upgrade Python versions, it always takes me a few minutes to remember the steps since I do this task so rarely. So here is a simple set of instructions that seem to work for me!

Install python 2.7

  • Download the Python Mac dmg file from the Python Downloads page
    Just open the dmg and follow the installer as you would with any application
  • You should now have Python 2.7 installed in:

NOTE: Even though we have installed python 2.7, your /usr/bin/python is still pointing to an older version of Python, so for example if you run easy_install, if will run from the older version of Python, and install packages into the library of the old Python installation.

So, on to step two of the install:
Let’s switch the /usr/bin/python link to point to the newest version of Python, and at the same time let’s create a soft link in the Python install folder that always points to the current install of Python. So the next time we upgrade, we will only need to change the “Current” version link.

#Create a soft link in /Library/Frameworks/Python.framework/Versions/
cd /Library/Frameworks/Python.framework/Versions/
ln -s 2.7 Current

#Switch the /usr/bin/python link to point to current python link
cd /usr/bin
rm -f python
ln -s /Library/Frameworks/Python.framework/Versions/Current/bin/python python

Install Setup Tools (this includes easy_install)

Download the egg file for your version of python (for this example, 2.7) from the Setup Tools Downloads page. To install setup tools just run the egg file like any other shell script:

sudo sh setuptools-0.6c11-py2.7.egg

Install pip (Using easy_install)

Open a new Terminal window session. You will need a new terminal session for easy_install to show up on the path.

sudo easy_install pip

Now we can install any python packages we want using pip!

Install Virtualenv (Using pip)

Now that we have pip, lets install a very important package called virtualenv!

pip install virtualenv

Thats it!

Now you will have Python 2.7 on your Mac, with easy_install, pip, and virtualenv ready to go.



  1. This is a great article šŸ™‚

    Comment by vernomcrp — June 2, 2012 @ 10:36 pm | Reply

  2. Very helpful! Much appreciated šŸ˜€

    Comment by Jason — July 7, 2012 @ 12:57 am | Reply

  3. This really helped! I was struggling previously.

    Comment by sumeet — July 8, 2012 @ 1:31 am | Reply

  4. What about all the python packages I have installed for 2.6? Is there any way I can easily move all the packages to 2.7 or do I have to re-install them all manually?

    Comment by Ats Nisov — July 8, 2012 @ 12:44 pm | Reply

    • I believe you have to download the 2.7 version of each library and install them again under 2.7.

      Comment by Brian — July 9, 2012 @ 7:58 pm | Reply

  5. This is a fantastic article, I’ve literally 24 hours trying to get something to work cheers!

    Comment by George — August 26, 2012 @ 7:47 am | Reply

    • Thanks, I am glad it helped!

      Comment by Brian — August 28, 2012 @ 10:16 am | Reply

  6. I’ve followed all the previous steps up to the easy_install of pip: It still thinks 2.6 is what my default is?
    Searching for pip
    Best match: pip 1.2.1
    Processing pip-1.2.1-py2.6.egg
    pip 1.2.1 is already the active version in easy-install.pth
    Installing pip script to /Library/Frameworks/Python.framework/Versions/2.6/bin
    Installing pip-2.6 script to /Library/Frameworks/Python.framework/Versions/2.6/bin

    Using /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pip-1.2.1-py2.6.egg
    Processing dependencies for pip
    Finished processing dependencies for pip
    Sarie:~ Sarie$

    Comment by Sara Kazemi — October 13, 2012 @ 4:58 am | Reply

    • However “python” does launch 2.7 and not 2.6 (it actually already had before I encountered this article).

      Comment by Sara Kazemi — October 13, 2012 @ 5:02 am | Reply

  7. Thanks! This tutorial is great. Has just enough info w/o indulging in technicalities.

    You should write more tutorials like this!

    Comment by William — November 3, 2012 @ 10:47 am | Reply

  8. Great article. I lost so much time on this stuff… and this post just solved it!

    Comment by Kevin — December 19, 2012 @ 5:30 am | Reply

  9. Extremely helpful…

    Comment by asd — January 25, 2013 @ 5:02 am | Reply

  10. Hi, the first step worked fine but when I arrived at the second part here’s what happend:

    Peter-Buddemeyers-MacBook-Pro:Versions Pete$ cd /usr/bin
    Peter-Buddemeyers-MacBook-Pro:bin Pete$ rm -f python
    rm: python: Permission denied

    Not sure why I wouldn’t have permission? This article is exactly what i’m looking for, any insight on how to proceed though the second step is much appreciated!
    Thanks much!

    Comment by Pete — April 22, 2013 @ 3:27 pm | Reply

  11. Figured it out!
    Peter-Buddemeyers-MacBook-Pro:bin Pete$ sudo rm -f python
    did the trick!
    thanks again

    Comment by Pete — April 22, 2013 @ 3:32 pm | Reply

  12. I think this is the second time in as many years that this post has saved me! Thanks again!

    Comment by ben — May 22, 2013 @ 11:38 am | Reply

  13. This is really working nicely. Thanks for such a nice and clear instruction. Even beginner like me can follow easily and it really works. Believe or not, I have tried everything such that I had to restore my whole mac once. Fortunately, I had time capsule which saved all my information, otherwise, I was screwed.
    I wish all the other post by other expert would have been something like this.

    Comment by fred — June 27, 2013 @ 1:40 am | Reply

  14. I have a question. How do I point back to my original system python

    Comment by Maylon Rojer — October 29, 2013 @ 1:29 pm | Reply

  15. I have googled a bunch of webpages before I visited yours. You really gave me a big help to figure out this problem. It’s great! thank you very much!

    Comment by Alex — February 20, 2014 @ 7:24 pm | Reply

  16. I was unable to configure python and django on my 10.6.8 osx and this amazing tutorial worked for me ! ..Did lots of web-searching before and was unable to find the right solution .. This is really a great tutorial guys. Cheers to my dear friend .. šŸ™‚

    Comment by Saurav — October 14, 2014 @ 7:30 am | Reply

  17. Sanjits-iMac:~ sanjitsingh$ cd /Library/Frameworks/Python.framework/Versions/
    Sanjits-iMac:Versions sanjitsingh$ ln -s 3.6 Current
    Sanjits-iMac:Versions sanjitsingh$ cd /usr/bin
    Sanjits-iMac:bin sanjitsingh$ rm -f python
    rm: python: Operation not permitted
    Sanjits-iMac:bin sanjitsingh$

    Comment by Sanjit Singh — February 19, 2017 @ 7:20 pm | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: