【发布时间】:2018-02-12 05:51:41
【问题描述】:
我正在尝试清理我的系统 python 环境。我之前使用 Homebrew 安装了另一个 python2 而不是系统提供的一个,我已经卸载了这个。
我认为现在我的 mac 上应该只有一个 python2。但是,which python 给出了/usr/bin/python,我注意到/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python 中还有另一个。
/usr/bin/ 下ls -l 的输出为
lrwxr-xr-x 1 root wheel 74 Jul 22 2015 pydoc2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pydoc2.6
lrwxr-xr-x 1 root wheel 74 Jul 22 2015 pydoc2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7
-rwxr-xr-x 2 root wheel 58416 Jul 15 2015 python
-rwxr-xr-x 5 root wheel 925 Sep 10 2014 python-config
lrwxr-xr-x 1 root wheel 18 Apr 8 2016 python2 -> /usr/bin/python2.7
lrwxr-xr-x 1 root wheel 75 Jul 22 2015 python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x 1 root wheel 82 Jul 22 2015 python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
lrwxr-xr-x 1 root wheel 75 Jul 22 2015 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 root wheel 82 Jul 22 2015 python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
-rwxr-xr-x 2 root wheel 58416 Jul 15 2015 pythonw
lrwxr-xr-x 1 root wheel 76 Jul 22 2015 pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
lrwxr-xr-x 1 root wheel 76 Jul 22 2015 pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
所以我认为这意味着/usr/bin/python 不是符号链接,它本身就是二进制文件。同时/usr/bin/python2.7 是/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 的符号链接。
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/下
lrwxr-xr-x 1 root wheel 7 Jul 22 2015 2to3 -> 2to32.7
lrwxr-xr-x 1 root wheel 8 Jul 22 2015 2to3-2 -> 2to3-2.7
-rwxr-xr-x 1 root wheel 288 Sep 10 2014 2to3-2.7
lrwxr-xr-x 1 root wheel 6 Jul 22 2015 2to32.7 -> 2to3-2
lrwxr-xr-x 1 root wheel 5 Jul 22 2015 idle -> idle2
lrwxr-xr-x 1 root wheel 7 Jul 22 2015 idle2 -> idle2.7
-rwxr-xr-x 1 root wheel 230 Sep 10 2014 idle2.7
lrwxr-xr-x 1 root wheel 6 Jul 22 2015 pydoc -> pydoc2
lrwxr-xr-x 1 root wheel 8 Jul 22 2015 pydoc2 -> pydoc2.7
-rwxr-xr-x 1 root wheel 215 Sep 10 2014 pydoc2.7
lrwxr-xr-x 1 root wheel 7 Jul 22 2015 python -> python2
lrwxr-xr-x 1 root wheel 14 Jul 22 2015 python-config -> python2-config
lrwxr-xr-x 1 root wheel 9 Jul 22 2015 python2 -> python2.7
lrwxr-xr-x 1 root wheel 16 Jul 22 2015 python2-config -> python2.7-config
-rwxr-xr-x 1 root wheel 34944 Jul 15 2015 python2.7
-rwxr-xr-x 1 root wheel 1818 Jul 15 2015 python2.7-config
lrwxr-xr-x 1 root wheel 8 Jul 22 2015 pythonw -> pythonw2
lrwxr-xr-x 1 root wheel 10 Jul 22 2015 pythonw2 -> pythonw2.7
-rwxr-xr-x 1 root wheel 34944 Jul 15 2015 pythonw2.7
lrwxr-xr-x 1 root wheel 9 Jul 22 2015 smtpd.py -> smtpd2.py
-rwxr-xr-x 1 root wheel 18681 Sep 10 2014 smtpd2.7.py
lrwxr-xr-x 1 root wheel 11 Jul 22 2015 smtpd2.py -> smtpd2.7.py
但是,/usr/bin/python 和 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 似乎是相同的二进制文件,因为它们都给出了
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
当我运行它们时。
我很困惑这两个二进制文件是否表示相同的 python 解释器?但是为什么它们是两个独立的二进制文件呢?
【问题讨论】:
-
/usr/bin条目lrwxr-xr-x 1 root wheel 75 Jul 22 2015 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7是/System/...下的符号链接 - 它们是相同的。 -
@metatoaster 但是
/usr/bin/python不是/usr/bin/python2.7的符号链接?
标签: python macos python-2.7