CentOS7 安裝 Python 3.6.1
在CentOS底下預設是Python 2.7版
以下是安裝Python 3.6.1版本方式
先安裝gcc
sudo yum install gcc
安裝openssl-devel [我碰到沒裝就會有"pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available"錯誤]
sudo yum install openssl-deve
下載Python 3.6.1
cd /usr/src
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
tar xzf Python-3.6.1.tgz
安裝Python 3.6.1 [要開啟shared 要不然安裝mod_wsgi 一直會錯誤,如果有問題就重新安裝一次Python]
cd Python-3.6.1
sudo ./configure --enable-shared --prefix=/usr/local
sudo make altinstall
測試Pyhton 3.6.1
python3.6 -v
測試pip
pip3.6
把pip3.6可以用sudo執行
sudo visudo
# 找到secure_path = /sbin:/bin:/usr/sbin:/usr/bin 這一行,後面加上 /user/local/bin
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/