3

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.

2
  • Why was the default python installation not sufficient? Commented Aug 23, 2012 at 1:42
  • Since you said you are new to mac I am assuming you weren't aware that python is installed by default on mac Commented Aug 23, 2012 at 1:47

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

If I remember correctly, you may want to do a "sudo port activate python". What does "which python" tell you? If it's /usr/bin/python, you're running OSX Python. If, OTOH, it's /usr/local/bin/python you're probably using the ports version.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.