开发者

Why is there so many Pythons installed in /usr/bin for my Snow Leopard? What decides which one is the System Python?

Why is there so many Pythons installed in /usr/bin for my Snow Leopard? What decides which one is the System Python?

When I simply type "p开发者_开发问答ython" it is 2.6.1 ~ but this doesn't seem to be the "System Python", why not? How does one change system Python and what are the drawbacks?


My snow leopard only has python 2.5 and 2.6 installed, so it's not that many. You may have additional pythons installed (i.e. python3.0), either system wide (in /usr/bin/) or through macports (/opt/local).

The default system python is defined through a setting,

defaults write com.apple.versioner.python Version 2.5

will change the default to 2.5. You can also use an environment variable, i.e. for bash:

export VERSIONER_PYTHON_VERSION=2.5

All of this is documented in the python manpage,

man python

Overall, it's better not to change the system default. It's what OSX may depend on for certain scripts, and you never know if these scripts work as expected on different versions. Especially Python 3 is different, and may really break your whole system.

If you want a different python to be used for your own scripts, either

  1. Use virtualenv (always good)
  2. Change your PATH and make sure your preferred python is included before the /usr/sbin one
  3. Be explicit, invoke the script using /my/preferred/python
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜