CentOs 6.x 升级 Python 版本

很文博客
很文博客
管理员
11398
文章
0
粉丝
网站技术评论911字数 440阅读模式
广告也精彩

在CentOS 6.X 上面安装 Python 2.7.X

CentOS 6.X 自带的python版本是 2.6 , 由于工作需要,很多时候需要2.7版本。所以需要进行版本升级。由于一些系统工具和服务是对 Python 有依赖的,所以升级 Python 版本需要注意。

升级步骤

如何欢乐的,没有痛苦的升级python版本 ,往下看 …文章源自很文博客https://www.zhenjiekeji.com/很文博客-https://www.zhenjiekeji.com/11192.html

更新系统和开发工具集

更新指令文章源自很文博客https://www.zhenjiekeji.com/很文博客-https://www.zhenjiekeji.com/11192.html

  1. yum -y update
  2. yum groupinstall -y 'development tools'

另外还需要安装 python 工具需要的额外软件包 SSL, bz2, zlib文章源自很文博客https://www.zhenjiekeji.com/很文博客-https://www.zhenjiekeji.com/11192.html

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

源码安装Python 2.7.x

  1. wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
  2. xz -d Python-2.7.8.tar.xz
  3. tar -xvf Python-2.7.8.tar

安装详情:

  1. # 进入目录:
  2. cd Python-2.7.8
  3. # 运行配置 configure:
  4. ./configure --prefix=/usr/local
  5. # 编译安装:
  6. make
  7. make altinstall
  8. # 检查 Python 版本:
  9. [root@dbmasterxxx ~]# python2.7 -V
  10. Python 2.7.8

设置 PATH

为了我们能够方便的使用Python,我们需要设置系统变量或者建立 软连接将新版本的 Python
加入到 path 对应的目录 :文章源自很文博客https://www.zhenjiekeji.com/很文博客-https://www.zhenjiekeji.com/11192.html

  1. export PATH="/usr/local/bin:$PATH"
  2. or
  3. ln -s /usr/local/bin/python2.7 /usr/bin/python
  4. # 检查
  5. [root@dbmasterxxx ~]# python -V
  6. Python 2.7.8
  7. [root@dbmasterxxx ~]# which python
  8. /usr/bin/python

安装 setuptools

  1. #获取软件包
  2. wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
  3. # 解压:
  4. tar -xvf setuptools-1.4.2.tar.gz
  5. cd setuptools-1.4.2
  6. # 使用 Python 2.7.8 安装 setuptools
  7. python2.7 setup.py install

安装 PIP

  1. curl https://bootstrap.pypa.io/get-pip.py | python2.7 -

修复 yum 工具

此时yum应该是失效的,因为此时默认python版本已经是2.7了。而yum需要的是2.6 所以:文章源自很文博客https://www.zhenjiekeji.com/很文博客-https://www.zhenjiekeji.com/11192.html

  1. [root@dbmasterxxx ~]# which yum
  2. /usr/bin/yum
  3. #修改 yum中的python
  4. 将第一行 #!/usr/bin/python 改为 #!/usr/bin/python2.6
  5. 此时yumok

总结

  1. Python 版本升级过很多遍,每次都有问题,此方法来自互联网,经过使用,没有问题,特此总结一下
文章源自很文博客https://www.zhenjiekeji.com/很文博客-https://www.zhenjiekeji.com/11192.html文章源自很文博客https://www.zhenjiekeji.com/很文博客-https://www.zhenjiekeji.com/11192.html

工具:作品在线观看

女优:最新作品观看

中文:国语在线观看

weinxin
我的微信
微信号已复制
扫一扫更精彩
大家的支持是我更新的动力!!!
 
广告也精彩
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证
加载失败