1

I use Windows. I wrote a Python 3.1 script that my Mac-using friend would like to run, but we can't get Python 3.1 to work right on his Mac. I think the problem is that the Python 3.1 framework is not being installed. Here's exactly what what I did and why I think this is the problem.

I downloaded Python 3.1.2 from the Python download page (this file). I opened the file, then opened "Python.mpkg". I proceeded with the install wizard, and I made sure to check the box to install "Shell profile updater" during the wizard. I went to "/Applications/Python 3.1" and double-clicked "Update Shell Profile.command".

Next I selected the python script I wrote and selected "File", "Get Info" in the menu bar. Under "Open With" I selected "PythonLauncher" from "/Applications/Python 3.1". I then clicked the "Change All" button. Now I double-clicked my program to run it, but it was run by Python 2.5.1 instead of Python 3.1. (I'm sure of this, I wrote a program to "print(sys.version)".)

So now I tried to figure out why the "PythonLauncher" from "/Applications/Python 3.1" is using Python 2.5.1. I opened "PythonLauncher" and found that the interpreter for "Python Script" is "/usr/bin/pythonw". So I went to "/usr/bin/" and discovered that "pythonw" was an alias pointing to "/System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5". Obviously this should be version 3.1 instead. So I went to "/System/Library/Frameworks/Python.framework/Versions/" and discovered that the only sub-folders are "2.3" and "2.5". Where's 3.1?

dln385
  • 11,630
  • 12
  • 48
  • 58

3 Answers3

2

Take a look at PythonBrew. It made installing Python on my Mac a lot easier.

Also this might help:

Is there a Python Equivalent of Ruby's RVM?

Community
  • 1
  • 1
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • There's no need to build your own if you are just trying to use Python3 vs Python2 as the OP is. The python.org binary installers are perfectly fine as long as you run the documented command to set up your PATH properly. – Ned Deily Nov 24 '10 at 00:00
1

Python Launcher.app is a somewhat neglected app; there have been some discussion about removing it all together because it could be somewhat of a security risk if someone downloads arbitrary Python scripts from the web. It can also be kind of hit or miss if you have multiple Python versions installed. And many people just run Python from a terminal window command line so they don't need Python Launcher.app and that's probably the safest thing to do. To do so, you should first run the Update Shell Profile command in /Applications/Python 3.1 which will ensure that the proper Python framework bin directory is added to your shell path. Then you can just type:

$ python3 /path/to/script.py

That said, you can make Python Launcher work by changing the interpreter path to:

/Library/Frameworks/Python.framework/Versions/3.1/bin/python3

but I discourage you from doing so.

Another better GUI option is to launch IDLE.app and drag-and-drop files onto it in the dock or open them in its File menu.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151
0

The versions in /System/Library/Frameworks/Python.framework/... were put there as part of OS X. They should be left alone. (See this question.)

.dmg files downloaded from python.org install to /Library/Frameworks/Python.framework/.... These are user-installed, so you can install/uninstall/move however you like. These installers also created symlinks in /usr/local/bin.

You can add either /Library/.../3.1/bin or /usr/local/bin to your path in your shell if you want python3 to be on your path.

Community
  • 1
  • 1
snapshoe
  • 13,454
  • 1
  • 24
  • 28
  • In general, you should always add the framework bin directory, in this case `/Library/.../3.1/bin` to your path and not just local `/usr/local/bin` because packages installed with Distutils (or any of the wrappers of it, like `easy_install` or `pip`) will install any package scripts into the framework `bin` directory by default. – Ned Deily Nov 24 '10 at 09:01