python安装

时间:2022-10-13 12:08:15

1.下载python

​https://www.python.org/downloads/release/python-352/​

2.安装依赖的包

yum install -y bzip2-devel ncurses-devel gdbm-devel openssl-devel readline-devel zlib-devel sqlite-devel

3.安装python

tar zxvf Python-3.5.2.tgz 
cd /lost+found/Python-3.5.2
./configure --prefix=/usr/local/python

python安装

make
make install

python安装

4.进入python命令行模式

cd /usr/local/python/bin
./python3.5

python安装

退出命令 exit()

python安装

5.替换系统默认的2.6python

mv /usr/bin/python /usr/bin/python2.6
ln -s /usr/local/python/bin/python2.7 /usr/bin/python

这个时候输入python进行验证

python安装

由于升级python后,导致了yum与python的不兼容

需要修改yum

vim /usr/bin/yum

第一行改成:#!/usr/bin/python2.6即可,由于yum不兼容python2.7所以改成2.6即可

安装PIL扩展

yum install python-devel