Centos6.10 安装Python 2.7.16
微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位
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 或者: ./configure --enable-optimizations make && make altinstall configure时加上enable-optimizations,启用PGO优化,让Python在运行时能变得更快。make 加altinstall参数,避免覆盖原来安装在/usr/bin/python 的版本
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/
参考:
https://www.voidking.com/dev-centos68-python26-to-python27/
https://www.cnblogs.com/luckyleaf/p/10666734.html
pip install web.py==0.51
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in <module>
from pip import main
ImportError: cannot import name main
解决方法:
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
sudo python get-pip.py
本文为转载文章,版权归原作者所有,不代表本站立场和观点。