CentOS7.4默认安装了Python 2.7.5,可以使用python -V查看。
记录一下安装CentOS7.4下安装Python3.5。
1). 安装相关包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
2).下载Python3.5.4源码包
wget https://www.python.org/ftp/python/3.5.4/Python-3.5.4.tar.xz
3).编译安装
tar xf Python-3.5.4.tar.xz -C /usr/local/src/
cd /usr/local/src/Python-3.5.4
./configure --prefix=/usr/local/python3
make && make install
4).更新pip
/usr/local/python3/bin/pip3 install --upgrade pip
/usr/local/python3/bin/pip3 list
5).备份python2.7
cd /usr/bin/
mv python python.bak
6).创建软连
ln -s /usr/local/python3/bin/python3 /usr/bin/python
7).查看版本
python -V
8).修改yum配置文件
vim /usr/bin/yum
#!/usr/bin/python2.7
vim /usr/libexec/urlgrabber-ext-down
#! /usr/bin/python2.7
网友评论