升级Python到2.7.15 on CentOS 6 x64

Centos 6 自带的2.6版本队友有些情况总会出现各种错误,例如:

File "/usr/lib/python2.6/site-packages/pip/_internal/index.py", line 526 
{str(c.version) for c in all_candidates}, ^ 
SyntaxError: invalid syntax

明确你的Linux版本

cat /etc/redhat-release

安装依赖:

yum groupinstall -y "Development tools"
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel

下载最新版本并编译安装

cd /tmp
wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
tar zxf Python-2.7.15.tgz
cd Python-2.7.15
./configure
make && make install

#新版目录

ll -tr /usr/local/bin/python*

#系统自带老版本目录

ll -tr /usr/bin/python*

备份老版本命令,创建新版本软连接

mv /usr/bin/python /usr/bin/python.old
rm -f /usr/bin/python-config
ln -s /usr/local/bin/python /usr/bin/python && ln -s /usr/local/bin/python-config /usr/bin/python-config && ln -s /usr/local/include/python2.7/ /usr/include/python2.7

检查一下是否正确

python --version

为新版 Python 安装 setuptools

wget https://bootstrap.pypa.io/ez_setup.py -O - | python
easy_install pip

然后就可以pip安装了

pip install itgeeker

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

奇客罗方公众号 奇客罗方小程序 奇客罗方客服 ITGeeker Telegram

网站由ITGeeker技术奇客开发并管理;隶属于GeekerCloud奇客罗方智能科技
Site designed and developed by ITGeekerwhich is a sub-website of GeekerCloud
网站地图 | 沪ICP备2021031434号-4