操作系统您现在的位置是:首页 > 博客日志 > 操作系统

Centos6.10 安装Python 2.7.16

<a href='mailto:'>微wx笑</a>的头像微wx笑 2023-11-14操作系统 0 0关键字: Centos  Python  

系统环境:CentOS 6.10 64位Python版本:2.71.升级下系统yum install eple-release -yyum update -y2.下载python 2.7,编译安装wget https://www.python.org/ftp/python/2.7.16/P

系统环境:CentOS 6.10 64位UA5无知

Python版本:2.7UA5无知

1.升级下系统UA5无知

yum install eple-release -yUA5无知

yum update -yUA5无知

2.下载python 2.7,编译安装UA5无知

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
或者:
./configure --enable-optimizations
make && make altinstall
configure时加上enable-optimizations,启用PGO优化,让Python在运行时能变得更快。make 加altinstall参数,避免覆盖原来安装在/usr/bin/python 的版本

3.修改默认pythonUA5无知

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,需要修改下,不然没办法使用。UA5无知

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

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

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/


UA5无知

参考:UA5无知

https://www.voidking.com/dev-centos68-python26-to-python27/ UA5无知

https://www.cnblogs.com/luckyleaf/p/10666734.html UA5无知


UA5无知

pip install web.py==0.51UA5无知

Traceback (most recent call last):UA5无知

  File "/usr/bin/pip", line 7, in <module>UA5无知

    from pip import mainUA5无知

ImportError: cannot import name mainUA5无知


UA5无知

解决方法:UA5无知

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py UA5无知

sudo python get-pip.pyUA5无知

本文为转载文章,版权归原作者所有,不代表本站立场和观点。

很赞哦! () 有话说 ()