How can I install Python 3.2 along side my current Python 2.7 installation on Mac OS 10.6.7?
August 5, 2011 11:44 AM   Subscribe

I want to install Python 3.2 in addition to the already installed Python 2.7. Can I do that in Mac OS 10.6.7?

I am new to programming and I taking the MIT opencourseware 6.00 Introduction to Computer Science and Programming, which was taught using Python 2. I am also starting a project at work and am using the book Bioinformatics Programming Using Python, which uses Python 3. I have Python 2.7 installed. Can I install 3.2 on Mac OS 10.6.7 and have both versions available? I understand 2 and 3 are very similar and that there are workarounds but I learn much better when I can work in an environment that is identical to either the course or the book. Googling gives me answers for which to pick but not how to install both simultaneously. Having IDLE working for both would be a bonus.
posted by jwwarren to Computers & Internet (6 answers total) 2 users marked this as a favorite
Yes, I have 2.6, 2.7, and 3.2 installed side-by-side using MacPorts— it doesn't consider them to conflict; you can just install both packages. I'm pretty sure I've installed 3.1 at times as well without breaking anything. The python_select tool lets you choose which one is the "default" (by making symlinks); I'd leave that at 2.x and invoke 3.2 explicitly when you want it.
posted by hattifattener at 11:52 AM on August 5, 2011 [2 favorites]

python_select went obsolete with (I think) the 2.0 MacPorts release. Now, selecting the active port is integrated into port itself. It'll tell you what to do. To be honest, I doubt you'll need to select the active port; just use the right executable in you #! line.

I don't know if you can get IDLE to work with them both but I do know you'll be much better off in the long run learning to use a proper editor (aquamacs, bbedit, etc).
posted by chairface at 12:15 PM on August 5, 2011

Here's what I did, according to my notes a while back when I installed 3.0a1:

1. Download Python 3.0a1
2. Unpack the archive.
3. Go to /usr/local and make a directory "sudo mkdir py3k" (This is
probably not needed, but that's what I did).
4. From the directory where the Python 3.0a1 was unpacked run
./configure --prefix=/usr/local/py3k
5. make
6. sudo make altinstall
7. sudo ln /usr/local/bin/py3k/python3.0 /usr/bin/python3.0

8. type "python3.0"
9. print("Hello world!")
10. Be happy!

You might want to choose to write python3 instead of python3.0 the way I did, but without creating an extra directory, just using --prefix=/usr/local

The key is step 6 where specifying "altinstall" indicates that this is an alternate version to the main one - thus not touching it.

Currently, I have multiple versions of python installed (2.4, 2.5, 2.6, 2.7, 3.1). Python3.1 and idle3 are both found /usr/local/bin/ I might have installed things slightly differently this time then when I made notes for 3.0a1

I never use idle ...

Hope it helps ... and please do a backup before you try to reproduce the above! :-/
posted by aroberge at 12:41 PM on August 5, 2011

$ ruby -e "$(curl -fsSL" # installs homebrew
$ brew install python3
posted by gregglind at 1:20 PM on August 5, 2011 [1 favorite]

Seconding MacPorts. It's about as painless as open source gets.
posted by Blazecock Pileon at 2:12 PM on August 5, 2011

Best answer: Thank you all for your replies. The installer packages (I found them HERE) for both 2.7.2 and 3.2.1 create folders in applications that are independent and each include IDLE. This is what I was hoping to do. Thanks again.
posted by jwwarren at 6:31 AM on August 8, 2011

« Older Its sad I dont remember authors/titles from...   |   hip doctor Newer »
This thread is closed to new comments.