Mac How-to Easy Manage Change/Switch Python Multiple-Versions

April 24th, 2012 by Regaz



This Article will Guide you Through Python Multi-Versions Installation, Setup and Management.

The Easiest Way on Installing and Managing Python Mac OS X is Prepared by Installing and Updating the Macports.

So to Make your Developer Way and Experience Easier and more Pleasant on a BSD Based Mac OS X I Strongly Encourage You to Setup and Use the MacPorts for Installing and Managing Packages.

The General Command Form for Installing a Package by the MacPorts take the Form:

sudo port install <packagename>

The Fundamental 2 Steps for Successfully Managing a Python Multi-Version Installing are:

  1. Setup the PATH
  2. Switch Between Python Versions by the Macports select Command
  • To Strongly Setup the Python PATH you should Edit the Main Shell Configuration Files:
    • ~/.bashrc
    • ~/.profile

    Inserting Near to the Top of Both the Following Configuration Line:

    export PATH=/opt/local/bin:/opt/local/sbin:$PATH

    If you Make your Changes on Terminal be Sure after to Re-Load the Shell…

  • After to Change/Switch between Python Versions you simply Perform on Terminal:
    sudo port select --set python <X.Y>

    Example:

    sudo port select --set python python27

    To Find the Python Versions Currently at your Disposal on the System:

    port select --list python

    To Show the Python Version Currently Active on the System:

    port select --show python

If you Correctly Setup the Path after All Should Work like a Charm ;)

Another Interesting Mac-Python Tutorial is Here:

Tags: , , , ,