[TOC]
#查看当前所有Python版本路径
appledeMBP:~ apple$ which python2.7
/usr/local/bin/python2.7
appledeMBP:~ apple$ which python3.5
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
appledeMBP:~ apple$ which python3.7
/usr/local/bin/python3.7
appledeMBP:~ apple$ which python
/usr/local/bin/python
appledeMBP:~ apple$ which python3
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
appledeMBP:~ apple$ which python2
/usr/local/bin/python2
下面的随意看看就行,都是旧版本了
#查看当前Python版本
appledeMBP:~ apple$ python --version
Python 3.5.1
查看Python路径
appledeMBP:~ apple$ which python
/usr/local/bin/python
查看全部Python路径
appledeMBP:~ apple$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public
查看Python3路径
appledeMBP:~ apple$ which python3
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
appledeMBP:~ apple$
查看pip2版本
appledeMBP:~ apple$ pip2 --version
pip 18.0 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
查看pip3版本
appledeMBP:~ apple$ pip3 --version
pip 18.1 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip (python 3.5)
查看python版本
appledeMBP:~ apple$ python --version
Python 3.5.1
查看Python3版本
appledeMBP:~ apple$ python3 --version
Python 3.5.1
appledeMBP:~ apple$
下面是网友总结的:
Mac系统自带python路径为/System/Library/Frameworks/Python.framework/Version
这里可能会有多个python版本,里面Current存放系统当前python版本,进入Current/bin
,
在终端输入./python --version
即可查看系统当前python版本
(注:若使用python --version
命令是查看用户当前python版本而不是系统python版本)
HomeBrew安装python路径为/usr/local/Cellar/python
里面存放HomeBrew所安装版本,
进入2.7.13/bin
,在终端输入./python --version
即可查看用户当前使用的python版本。
如果使用brew工具正确安装python的情况下,用户当前python版本会是新安装的python
系统命令默认路径在/usr/bin
,用户命令默认路径在/usr/local/bin
(brew安装的命令默认在这个路径下)。
如果存在相同的命令,则会依据/etc/paths
文件中的环境变量顺序(前面优先于后面)依次查找,查看环境变量也可以在终端输入echo $PATH
查看,遵循左面路径优先于右面路径。