python現(xiàn)在分為python2和python3兩個版本,兩個版本都有很多人在用击蹲,沒辦法毡琉,都裝上吧,都學習一下
python2
mac本身是裝了python2的舍杜,但是我們進行python開發(fā)的話新娜,用這個系統(tǒng)自帶的不太好
- 很多系統(tǒng)組件依賴于它,如果不小心把它玩壞了...
- pip一些第三方庫會發(fā)生一些錯誤
最好的辦法是既绩,我們再裝一個python2
brew install python
成功如下
==>** Summary**
?? /usr/local/Cellar/python/2.7.11: 6,268 files, 84.3M, built in 3 minutes 46 seconds
如果出現(xiàn)其他的結(jié)果概龄,可能需要重新安裝brew,參考brew
然后把相關配置轉(zhuǎn)移到我們新裝的python2上
brew linkapps python
brew link --overwrite python
把
該翻墻的翻墻
如果遇到權限問題饲握,記得加上sudo
python3
安裝python3
brew install python3
使用三個版本的python
現(xiàn)在我安裝了2個版本的python私杜,加上本身的python一共3個蚕键,其實我發(fā)現(xiàn)它們并不沖突,各管各的
由于我們剛才更改了python相關配置衰粹,在終端輸入python
或python2
锣光,都使用的是新裝的python2
Python 2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
'>>>
如果輸入python
,出現(xiàn)信息如下
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
.>>>
這顯然是之前系統(tǒng)的python铝耻,請重新打開終端一次
在終端輸入python3
誊爹,則使用的是python3
Python 3.5.0 (v3.5.0:374f501f4567, Sep 12 2015, 11:00:19)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
`>>>
相應的一些命令也可以由此區(qū)分,例如pip
和pip3