开发者

What is the difference between Mac OS X pre-installed Python and the one from Python.org?

I am a new Mac (Snow Leopard) user and I found that Python is pre-installed in Mac OS X. What is the difference between Mac OS X pre-installed Python and the one from Python.org?

If I install the one from Python.org, will it break anything? Will it be redundant?

EDIT

What would be a good reason to prefer 开发者_Python百科the Python.org version, comparing identical version numbers head-to-head?


The Apple-supplied Python 2.6 in Mac OS X 10.6 (Snow Leopard) is currently 2.6.1 (and, based on previous OS X releases, it is unlikely Apple will update it to a newer version in a 10.6.x maintenance release). The most recent (and likely final) release of Python 2.6 is 2.6.6. So if you install the most recent python.org release, you will get the benefit of a large number of bug fixes that have been made over the lifetime of Python 2.6. There are some other differences. The python.org 2.6.x versions are built as 32-bit-only. The Apple-suppled version is built as a 32-bit/64-bit universal and will, by default, prefer to run in 64-bit mode when possible. Either one can lead to some issues when installing third-party packages with C extension modules that depend on other 3rd-party libraries. There needs to be at least one common architecture (be it 32-bit, i386, or 64-bit, x86_64) among all the components. Another difference is that the Apple-suppled 2.6 is linked with a new version of Tk 8.5; there are reported problems with the IDLE that comes with 10.6 and possibly with other applications using Tkinter. If you plan to use either, you may be better off with the python.org 2.6 which is linked with Tk 8.4.

On OS X, it is particularly easy and common to install multiple Python versions even of the same major version. If you do install the python.org version, by default the installer will modify your shell search PATH so that the python.org version is found first. It will also be available via the absolute path /usr/local/bin/python2.6. The Apple-suppled version will remain available as /usr/bin/python2.6.

FYI: Be aware that Python 2.7 has already been released and there are OS X installers for it available from python.org. A new, not upwards-compatible version of Python, Python 3, is also available (currently 3.1.2 with 3.2 coming in a few months) and is expected to gradually replace Python 2 in popularity as new features are only being added to Python 3.


It's impossible to tell without knowing which version(s) you're comparing. You're best off doing python --version on your default OS X install, and then checking release notes from that version to subsequent versions. My guess (I don't have OS X) is that you're likely running 2.4.x or 2.5.x. There'll be very few regressive differences from 2.4.x forward on the 2.x version tree. Python 3.x introduces syntax changes, which will break some existing code. Perhaps the most visible change is print becomes a function in 3.0, while still a statement in 2.x.

In general, amongst 2.x, syntax is only enhanced, not broken. The changes are going to be more in the libraries (i.e. the md5 module is deprecated at 2.6 in favor of the hashlib module).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜