user720129
user720129

Reputation: 119

How do I change the default Python version in my Mac Snow Leopard?

How do I change the default Python version used in my Mac Snow Leopard? I'm trying to switch from v2.5 to v3.0

Upvotes: 3

Views: 15743

Answers (5)

curious
curious

Reputation: 403

You want to create a symlink to the desired version.

cd /Library/Frameworks/Python.framework/Versions
sudo rm Current
sudo ln -s /Library/Frameworks/Python.framework/Versions/3.0 Current

This removes the current pointer to your default Python version and sets it to your 3.0 version.

Upvotes: 2

Alex
Alex

Reputation: 2040

Try the following: defaults write com.apple.versioner.python Version 3.2 in a terminal. Assuming you have 3.2 installed of course.

EDIT: As Neil Deily points out in his comment this only works with Python distributions shipped by Apple.

Upvotes: 1

colin
colin

Reputation: 86

I would first install Xcode on my machine (it comes on the installation disc that came with your computer). Then run Software Update to bring it up to date (at least to the most-current free version).

Then, download the Python 3.x source code and extract it. Do "./configure", "make" and "sudo make install" in that directory. These will install the new Python installation in /usr/local/bin (and other nearby places).

If all goes well, /usr/local/bin/python will be a Python 3 interpreter you can use. I would hesitate to overwrite the installed version of Python, since that might make trouble for python scripts shipped with the operating system. I never install anything in /usr; I let Software Update take care of that. For all the rest of my software needs, the "./configure ... make ... sudo make install" technique works very well on Snow Leopard once Xcode is installed.

Upvotes: 0

user2665694
user2665694

Reputation:

Is is not recommended to change the system Python installation on any system without any need. Better install Python 3.X in a different location and adjust your $PATH as needed. The Python installation may be needed for further functionality under the hood. So leave it as it is and install arbitrary Python interpreters in a different location. Macports and Brew will do that automatically. If you compile Python yourself:

 configure --prefix=/path/to/my/python/installation.

Upvotes: 3

Ned Deily
Ned Deily

Reputation: 85055

If you are reading the Apple-supplied Python man page (man python) on Mac OS X 10.6 (Snow Leopard), be aware that it is incorrect: Apple did not ship a Python 3.0 with 10.6. You'll need to install a Python 3 version yourself. The easiest way is to use a binary installer from python.org. But you can also use MacPorts or Homebrew or do it yourself. Also, be aware that support for Python 3.0 was dropped immediately with the release of Python 3.1. Python 3.2 is now current. However you install it, the Python 3 interpreter will be available as either python3 or python3.2. It does not conflict with Python 2 (python). You may need to adjust your shell PATH though. The python.org installer will do that for you; follow the installation instructions.

Upvotes: 1

Related Questions