1. 程式人生 > >CentOS/RedHat安裝Python3

CentOS/RedHat安裝Python3

stat 沖突 安裝 ack adl trac ons 出錯 sso

CentOS/RedHat安裝Python3

摘自:https://blog.csdn.net/mvpboss1004/article/details/79377019

CentOS/RedHat默認是帶Python2.7的,且無法通過yum等方式安裝Python3,只能通過源碼方式安裝。為避免安裝中python的沖突,可以按以下方式安裝。安裝完後,python3和python2都能正常運行。
註意,安裝中第一步yum安裝依賴包最好執行。沒有這些依賴,configure時就會缺少一些組件。導致後期如果要使用還要再編譯一次,非常麻煩。

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ zlib*
tar zxvf Python-3.6.4.tgz
cd Python-3.6.4
./configure --enable-optimizations --prefix=/usr/local --enable-shared
make
1 如果編譯出錯,提示
2 Failed to build these modules:
3 _ctypes
4 
5 
6 可以先安裝
7 yum install libffi-devel


make altinstall
cd /usr/bin
ln -s /usr/local/bin/pip3.6 pip3
ln -s /usr/local/bin/python3.6 python3

CentOS/RedHat安裝Python3