centos python版本_Centos 6 升级 Python 版本

Centos 6自带的python版本是 2.6 , 但是很多时候一些开发和使用需要2.7版本。接下来,我们升级Python版本从2.6-2.7或者你可以从2.6-3以上,步骤都是类似的。

1、更新开发工具集yum -y update

yum groupinstall -y 'development tools'

yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget

2、下载和解压你要更新至Python目的版本号wget http://mirrors.sohu.com/python/2.7.13/Python-2.7.13.tar.xz

xz -d Python-2.7.13.tar.xz

tar -xvf Python-2.7.13.tar

此过程,解压的文件非常之多。我更新至2.7.13,你随意。

3、编译cd Python-2.7.13

./configure --prefix=/usr/local

make && make install

此过程,你可能会遇到跟我一样的错误,不过我觉得可能性很小。是什么样的呢?请看,不过这个错误很容易解决,关键之处我加粗了。

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

checking for --enable-universalsdk... no

checking for --with-universal-archs... 32-bit

checking MACHDEP... linux2

checking EXTRAPLATDIR...

checking for --without-gcc... no

checking for --with-icc... no

checking for gcc... /home/soft/bin/gcc

checking whether the C compiler works... no

configure: error: in `/root/Python-2.7.13':

configure: error: C compiler cannot create executables

See `config.log' for more details

gcc已经安装,看一下目录就能知道错误原因和解决方法。

[root@cdh Python-2.7.13]#which gcc

/usr/bin/gcc

我做了软连接ln -s /usr/bin/gcc /home/soft/bin/gcc到/home/soft/bin/gcc

然后进行编译就通过了。

If you want a release build with all optimizations active (LTO, PGO, etc),

please run ./configure --enable-optimizations

4、验证python -V

which python

Python 2.7.13

至此,Python主体升级完毕,一些工具包可以意并安装,方便日后使用。

5、安装 setuptoolswget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz

tar -xvf setuptools-1.4.2.tar.gz

python2.7 setup.py install

6、安装 PIP

这是重要的,Python的一些库都需要使用pip安装,用起来十分方便。curl  https://bootstrap.pypa.io/get-pip.py | python2.7 -

比如安装flask,pymongo,virtualenv等可以通过pip安装。pip install Flask

pip install pymongo

pip install virtualenv

完结。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值