Set up python path in mac osx?

14,568

First let me preface by saying that OSX already comes with python installed. Lion and Mountain Lion have python2.7 as the system defaults.

Now assuming you really did want to use a macports version, my guess is that you only installed it, but didn't do the step of modifying your PATH to have it look first for macport installed executables...

Installing MacPorts

  1. Edit your ~/.profile
  2. Add this line: export PATH=/opt/local/bin:/opt/local/sbin:$PATH

The next time you open a shell, it will place the macports install location at the front of your path, giving you access to the executables.

Share:
14,568
Kakashi
Author by

Kakashi

Updated on June 04, 2022

Comments

  • Kakashi
    Kakashi about 2 years

    I installed python on mac os (mountain lion) with Macports. When I run $python It gives an error on "cannot import urandom" when I try to import pandas or matplotlib.

    If I run $python 2.7 Everything runs perfectly.

    I want to change python to use python2.7 always.

    I tried using sudo port select python python27. But that didn't help.

    Please help me on this, I'm new to mac.