How can I make python 2.6 my default in Mac OS X Lion?

﹥>﹥吖頭↗ 提交于 2019-11-28 04:25:41

Apple has provided two very simple ways to change the default python on OS X 10.6 Snow Leopard and 10.7 Lion. It's all detailed in the Apple man page for python(1):

$ man python
$ which python
/usr/bin/python
$ python -V
Python 2.7.1
#
# temporarily change version
#
$ export VERSIONER_PYTHON_VERSION=2.6
$ python -V
Python 2.6.6
$ unset VERSIONER_PYTHON_VERSION
$ python -V
Python 2.7.1
#
# persistently change version
#
$ defaults write com.apple.versioner.python Version 2.6
$ python -V
Python 2.6.6

After running the following:

defaults write com.apple.versioner.python Version 2.6

To make sure the packages you install with 'sudo' are installed for the correct Python version, also set the versioner option as a superuser:

sudo su
# Enter password
defaults write com.apple.versioner.python Version 2.6
exit

You have a few options:

  1. Change /usr/bin/python to a link to /usr/bin/python2.6
  2. Put /System/Library/Frameworks/Python.framework/Versions/2.6/bin in your path before /usr/bin
  3. Explicitly tell your scripts to use /usr/bin/python2.6
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!