So as I'm sure many of you have/will, I updated to OS X Mavericks earlier today. In general, Mavericks feels super snappy and refined. However, soon after installing, I noticed that when running Python 3 interactivly Python segfaults for no apparent reason; clearly a major issue. The good news is this issue only seems to affect Python 3, and only when Python 3 is in interactive mode. This means you can run Python 2 just fine and non-interactive Python 3 features, like doctests, still work. Python 3 graphical applications also seem to work. I'll update this post when I find a solution (or, if you find one, comment below!).
This problem exists because of this bug: http://bugs.python.org/issue18458. Basically, Python has code in Modules/readline.c that contains a workaround for a bug in libedit however the bug in libedit was fixed and Mavericks comes with the new version of libedit and the workaround now causes Python to segfault. The quick and dirty fix is to disable deadline processing by running the following command (from the bug document):
sudo mv readline.so readline.so.disabled
However this fix comes at the cost of disabling many of Python's history and editing features.
Note: To undo the previous fix run:
sudo mv readline.so.disabled readline.so
It turns out that this bug has already been fixed however the fix is not included in Python's binary installers for OS X. Most likely, since OS X 10.9 is now public, the Python community will soon provide new versions of the binary installers for OS X. However, until that happens, the solution is to uninstall Python and then reinstall via a package manager like Brew. Package managers install software by compiling directly from source so you know that you will always get the latest version. Below are directions.
CAVEAT: Don't follow these directions if you have MacPorts installed. It's never a good to have multiple package managers installed at the same time.
- Uninstall Python. Follow the directions here but substitute in your version number (e.g. replace 2.7 with 3.3).
- Install Xcode form the Mac App Store. Open it, and let it do its initialization.
- Install Xcode command line tools.
- Install Homebrew.
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
- Make sure Homebrew is good to go.
Fix any warning that
brew doctor gives. Usually, they come with a useful explanation. When in doubt, Google it. Once all warnings are fixed
brew doctor should say "Your system is ready to brew."
- Install Python.
brew install python3
And that's it! You should be good to go!