Centos6.10 安装Python 2.7.16

部署一个程序,

系统环境:CentOS 6.10 64位

Python版本:2.7

1.升级下系统

yum install eple-release -y

yum update -y

2.下载python 2.7,编译安装

wget https://www.python.org/ftp/python/2.7.16/Python-2.7.16.tar.xz
tar xvf Python-2.7.16.tar.xz
cd Python-2.7.16
./configure
make && make install

3.修改默认python

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

到这一步已经基本安装完毕,但还存在一些小问题需要调整

4.默认的yum 是python2.6,需要修改下,不然没办法使用。

vim /usr/bin/yum
将 #!/usr/bin/python 修改为 #!/usr/bin/python2.6

5.将Python2.6 的module文件拷贝到Python2.7中(不然在安装一些程序时,会提示一些module缺失,还是要拷贝)

cp -r /usr/lib/python2.6/site-packages/yum /usr/local/lib/python2.7/site-packages/
cp -r /usr/lib/python2.6/site-packages/rpmUtils /usr/local/lib/python2.7/site-packages/
cp -r /usr/lib/python2.6/site-packages/iniparse /usr/local/lib/python2.7/site-packages/
cp -r /usr/lib/python2.6/site-packages/urlgrabber /usr/local/lib/python2.7/site-packages/
cp -r /usr/lib64/python2.6/site-packages/rpm /usr/local/lib/python2.7/site-packages/
cp -r /usr/lib64/python2.6/site-packages/curl /usr/local/lib/python2.7/site-packages/
cp -p /usr/lib64/python2.6/site-packages/pycurl.so /usr/local/lib/python2.7/site-packages/
cp -p /usr/lib64/python2.6/site-packages/_sqlitecache.so /usr/local/lib/python2.7/site-packages/
cp -p /usr/lib64/python2.6/site-packages/sqlitecachec.py /usr/local/lib/python2.7/site-packages/
cp -p /usr/lib64/python2.6/site-packages/sqlitecachec.pyc /usr/local/lib/python2.7/site-packages/
cp -p /usr/lib64/python2.6/site-packages/sqlitecachec.pyo /usr/local/lib/python2.7/site-packages/


 



 

posted @ 2019-04-07 20:03  leafgood  阅读(1846)  评论(0编辑  收藏  举报