我是python的新手,我刚刚安装了python 3.7.2,至少那是我的IDLE告诉我的。但是,当我检查usr / bin时,仅看到python2.7。这是为什么?发生了什么事?
谢谢!
P.S .:我很确定这是我的机器看到的第一个也是唯一的python。
系统:IOS v.10.13.6
答案 0 :(得分:1)
现在, MAC OS X 预先安装了python2
,他们将其放置在/usr/local/bin
中就可以使用,并且该位置已经在系统路径。
如果您安装任何新版本,例如 Python3 + ,它将安装在/Library/Frameworks/Python.framework/Versions/<version>/bin/
上。
例如在我的情况下,全路径为/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
和/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
。
我已经使用 Homebrew 安装了 Python3.6 。
以下是我的终端机的有用日志。请看看。
»版本检查路径(哪个python )
Rishikeshs-MacBook-Air:~ hygull$ which python
/usr/local/bin/python
Rishikeshs-MacBook-Air:~ hygull$
哪个python3
Rishikeshs-MacBook-Air:~ hygull$ which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Rishikeshs-MacBook-Air:~ hygull$
哪个python3.6
Rishikeshs-MacBook-Air:~ hygull$ which python3.6
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Rishikeshs-MacBook-Air:~ hygull$
»开始和退出(python2,MAC OS X上的默认安装)
python
Rishikeshs-MacBook-Air:~ hygull$ python
Python 2.7.15 (default, Jan 12 2019, 21:07:57)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
Rishikeshs-MacBook-Air:~ hygull$
python3
Rishikeshs-MacBook-Air:~ hygull$ python3
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 03:02:14)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
Rishikeshs-MacBook-Air:~ hygull$
python3.6
(与上述相同,但是如果您有两个 python3 + ,则很有用,例如,如果您安装了 python3.6 和 python3.7 想使用 python3.6 )
Rishikeshs-MacBook-Air:~ hygull$ python3.6
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 03:02:14)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>