centos 中安装python3.7.x

环境: CentOS_7 (root用户)
软件版本: python_3.7.x 不通的版本把 x 换成相应的数字就行,下面以 python_3.7.3 为例子。


  • 安装依赖包

yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
  • 解压并编译源码

tar zxvf Python-3.7.3.tgz
cd Python-3.7.3/
./configure --prefix=/usr/local/python-3.7.3
make && make install
  • 配置软链接

ln -s /usr/local/python-3.7.3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python-3.7.3/bin/pip3.7 /usr/bin/pip3
  • 验证

python3 -V

Python 3.7.3
------
pip3 -V

pip 19.0.3 from /usr/local/python-3.7.3/lib/python3.7/site-packages/pip (python 3.7)



0
479