现在,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。
以下是我的终端的有用日志。请看一下。
» 版本检查路径 (which 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 默认安装)
蟒蛇
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.
>>>