Mac查看Python安裝路徑和版本

[TOC]python

#查看當前全部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$

下面是網友總結的:app

Mac系統自帶python路徑爲/System/Library/Frameworks/Python.framework/Version python2.7

這裏可能會有多個python版本,裏面Current存放系統當前python版本,進入Current/bin工具

在終端輸入./python --version便可查看系統當前python版本code

(注:若使用python --version命令是查看用戶當前python版本而不是系統python版本)ip

HomeBrew安裝python路徑爲/usr/local/Cellar/python 裏面存放HomeBrew所安裝版本,it

進入2.7.13/bin,在終端輸入./python --version 便可查看用戶當前使用的python版本。pip

若是使用brew工具正確安裝python的狀況下,用戶當前python版本會是新安裝的pythonio

系統命令默認路徑在/usr/bin,用戶命令默認路徑在/usr/local/bin(brew安裝的命令默認在這個路徑下)。class

若是存在相同的命令,則會依據/etc/paths 文件中的環境變量順序(前面優先於後面)依次查找,查看環境變量也能夠在終端輸入echo $PATH 查看,遵循左面路徑優先於右面路徑。

相關文章
相關標籤/搜索