CentOS/RedHat安装Python3
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