centos安装python3
1、查看安装默认安装位置
whereis python
2、python2.7默认安装是在 /usr/bin目录中,切换到/usr/bin/
cd /usr/bin/
3、安装相关的依赖包
yum install -y epel-release zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
4、安装pip
yum install python-pip
5、安装wget
pip install wget
6、下载python3安装包
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
7、编译python3源码包,解压
xz -d Python-3.6.8.tar.xz
tar -xf Python-3.6.8.tar
8、进入解压后的目录,依次执行下面命令进行手动编译
cd Python-3.6.8
./configure prefix=/usr/local/python3
make && make install
9、安装依赖zlib、zlib-deve
yum install zlib zlib
yum install zlib zlib-devel
10、添加软链接,将原来的链接备份
mv /usr/bin/python /usr/bin/python.bak
mv /usr/bin/pip /usr/bin/pip.bak
11、添加python3的软链接
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
vi /etc/profile
source /etc/profile
12、测试是否安装成功了
python -V
13、保证pythonh2正常使用
vi /usr/bin/yum
vi /usr/libexec/urlgrabber-ext-down
|