I downloaded a package installer for Python 2.6.1, but when I use the python command in terminal (bash) Apple's shipped 2.3.5 version loads up. How can I get 2.6.1 to load up instead?
You probably need to edit your ~/.profile file. It contains your PATH variable, which tells the command line where to find things. You can do so like this:
export PATH=/path/to/new/python:$PATH
That puts your new path as the first place to look.
I am running Leopard, 10.5.5. The python binary, /usr/bin/python
, is merely a symlink to the actual binary in the version specific Python folder. For example:
$ ls -l /usr/bin/python
lrwxr-xr-x 1 root wheel 72 Aug 31 2008 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python
And a look inside that /Versions
folder reveals this:
$ ls -l /System/Library/Frameworks/Python.framework/Versions/
total 8
drwxr-xr-x 7 root wheel 238 Aug 31 2008 2.3
drwxr-xr-x 13 root wheel 442 Nov 22 20:40 2.5
lrwxr-xr-x 1 root wheel 3 Aug 31 2008 Current -> 2.5
With the help of the ln
command to create symlinks, you will be able to set the python
in your path to point to the version of python you want to use.
Apart of making symlink or putting /usr/local
at the front of PATH
environment variable, you can try to make use of MacPorts. Installing Python from ports takes bit longer (it has to be compiled from source), but ports provide you with the most reliable way of installing PIL into your Python (apart of issuing sudo apt-get install python-imaging
in Ubuntu...).
you could try typing python2.6
instead of python
. This may require you to set up your PATH "correctly"
I'd recommend that if you'd like to do single machine python development on your Mac to use MacPorts. It gives you the control (since by default, everything gets installed in /opt/local
) over which version of python you use (assuming you can modify your $PATH envariable). It also makes it simple and easy to have installed multiple versions of python simultaneously, along with their optional binary packages.
The MacPorts path to python2.6 on my system is:
/opt/local/bin/python2.6
if you use something like #!/usr/bin/env python2.6
, you may need to modify your PATH environment variable to include MacPorts (or your other python2.6 version) in order to pull in the desired version of python when the script runs
Here's an example command which assuming BASH shell, and the location to my MacPorts bin
directory:
export PATH=/opt/local/bin:$PATH