系統環境:
OS : CentOS Linux release 7.3.1611 (Core)python
1. 默認Python安裝環境
- 通常狀況下,Linux系統會預裝Python,版本比較低。好比,CentOS 7 系統通常預裝的是Python 2.7.5。
![](http://static.javashuo.com/static/loading.gif)
- 使用命令
which python
能夠查看當前Python的安裝路徑:
![](http://static.javashuo.com/static/loading.gif)
- python使用pip做爲包管理器,默認未安裝,可以使用yum直接安裝:
![](http://static.javashuo.com/static/loading.gif)
- python能夠使用virtualenv在本地構建多個虛擬環境
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
通常狀況下直接使用Python 2.7便可,當明確須要使用Python 3時,可進行編譯安裝。sql
2. 編譯安裝Python
- 安裝Python依賴 zlib-devel openssl-devel sqlite-devel gcc g++
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
- 安裝完成後,添加軟連接,將Python 3相關命令加到到系統環境變量
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
安裝完成,效果以下:
spa
自此,系統原生自帶的Python2.7和編譯安裝的Python3.6都可使用。3d