2

I am on osx-mavericks and I am encountering a Segmentation fault: 11 issue.

This SO post: Segmentation fault: 11 in OS X says that this could be caused by python 2.7.5

I attempted to upgrade python to the next version.

When I do

port installed | grep python

I see:

  python27 @2.7.6_0 (active)

However, when I run

python --version 

I get

 Python 2.7.5

It does the same behavior for python2.7 --version as well. Can anyone help me with this? How do I get python up to 2.7.6? Is it already there and just acting weird? Do I still have 2.7.5 on the machine somewhere? (Also, its worth noting I'm a bit new to the osx development environment)


Thanks to all.

I found the macports python at /opt/local/bin/python, whereas which python showed me /usr/local/bin/python. I changed the order in which these two directories are seen in my PATH and everything seems to work now.

Community
  • 1
  • 1
Erotemic
  • 4,806
  • 4
  • 39
  • 80
  • 1
    Run `which python` and make sure, the version installed by Macports is actually included in your `$PATH`. – Jens Erat Jan 12 '14 at 00:01
  • Also note that you can install different versions under MacPorts. Then to switch between them you can run `port select python python27` (do not include `python27` if you want to see which versions are available. – Timothy Brown Jan 13 '14 at 18:33
  • The answer below isn't really the right way of doing things with MacPorts. Use `port select --list python` for a list of python versions, and, as @TimothyBrown mentions: `port select --set python python27` for the 2.7.6 MacPort. – Brett Hale Jan 18 '14 at 04:07

1 Answers1

4

OSX comes with python. It is likely that the version of python on your path is the out of box version. If you use

which python

you should get the directory location of the python you are calling and you can see if it is the macports or OSX version. The OSX Python on my 10.8 mac is in /Library/Frameworks/Python.framework .

Using Ned Deily's comment below you can find the location of the python you want to use from the terminal. Then you can add a line to your ~./bash_profile to set the PYTHONPATH to the version you want to use like this.

export PYTHONPATH=$PYTHONPATH:/path/to/your/python

Then you must reopen the terminal or source the .bash_profile.

source .bash_profile

Then use the which command again to make sure you have the version you want.

jeremyjjbrown
  • 7,772
  • 5
  • 43
  • 55
  • 1
    The Apple-supplied Pythons are in `/System/Library/Frameworks` and in `/usr/bin`. `/Library/Frameworks` and `/usr/local/bin` are the locations for some third-party installations like the python.org Pythons. MacPorts Pythons are installed by default in `/opt/local/Library/Frameworks` and `/opt/local/bin`. – Ned Deily Jan 12 '14 at 00:31
  • There is *so* much misinformation about this on SO and elsewhere. This answer was the only one that worked. – AWrightIV Aug 22 '14 at 20:48
  • Yes it can be a headache. Mostly because Apple keeps moving the default locations around. Java is even worse. – jeremyjjbrown Aug 22 '14 at 23:27
  • in my experience with the latest (2.7.8) you don't need to do any of this anymore. a `port upgrade` will have your default python to the MacPorts version – Dexter Legaspi Sep 29 '14 at 01:16
  • @Dexter - Good, Brew installs it properly as well. Bu,t I think users should still understand how it really works. – jeremyjjbrown Sep 29 '14 at 01:25