ilyas patanam
ilyas patanam

Reputation: 5324

How many versions of python are pre-installed on OS X?

According to the documentation, the Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. Does this mean there are two copies of python installed?

In /usr/bin/, I have python, python2.5, python2.6, and python2.7. While python2.5, python2.6, and python2.7, are links to their respective versions in /System/Library/Frameworks/, it seems that python is not a link and is the executable itself.

My output of ls-l in usr/bin/python is:

-rwxr-xr-x 2 root wheel 58608 Mar 7 00:24 python lrwxr-xr-x 1 root wheel 75 Mar 7 00:24 python2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 lrwxr-xr-x 1 root wheel 75 Mar 7 00:24 python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 lrwxr-xr-x 1 root wheel 75 Mar 7 00:24 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

Upvotes: 1

Views: 359

Answers (2)

Ned Deily
Ned Deily

Reputation: 85045

On modern OS X systems, /usr/bin/python is a special "wrapper" executable provided by Apple to allow management of which version of Python and which CPU architecture (e.g. 32-bit or 64-bit) is executed by /usr/bin/python. There are more details in a previous SO answer and in Apple's python man page (man 1 python). As you noticed, the versioned Python files (/usr/bin/python2.7 et al) are symlinks to the universal Python executables in /System/Library/Frameworks.

This is another reason, by the way, why you should not attempt to modify files in /usr (other than /usr/local) or in /System/Library; they are not always what you think they are. Files in those locations are part of OS X and are managed by Apple.

Upvotes: 3

Martin Konecny
Martin Konecny

Reputation: 59601

Do a /usr/bin/python -V to see what the version of that python is. That binary contains the python interpreter.

/System/Library/Frameworks/Python.framework should contains the python system libraries that you import. You can verify this by starting the python in the shell (the following is output from a Linux box):

$ python
Python 2.7.6 (default, Mar 22 2014, 15:40:47) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7']

Upvotes: 0

Related Questions