为什么同一个可执行文件会根据用户/超级用户状态报告两个不同的版本?
host:tmp$ /usr/bin/python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
host:tmp drf$ sudo bash
bash-3.2# /usr/bin/python
Python 2.6.8 (unknown, Mar 9 2014, 22:16:00)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
bash-3.2# ls -la /usr/bin/python
-rwxr-xr-x 2 root wheel 58608 May 15 17:32 /usr/bin/python
bash-3.2# file /usr/bin/python
/usr/bin/python: Mach-O universal binary with 2 architectures
/usr/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture i386): Mach-O executable i386
答案 0 :(得分:2)
/usr/bin/python
是一个代理程序,它根据环境变量在不同版本的python之间进行选择。 python(1)手册页详细描述了这一点。简而言之,python解释器版本可以通过以下方式选择:
VERSIONER_PYTHON_VERSION
环境变量定义为系统python版本或 Version
偏好设置的com.apple.versioner.python
属性
醇>
在任何一种情况下,它只会从 /System/Library/Frameworks/Python.framework/Versions 中的解释器中选择。