Upgrade Python 2.6.6 system to version 2.7.10

Source: Internet
Author: User
Tags install openssl

CentOS 6 system default Python version is: 2.6.6 usually encountered in the use of a lot of library requirements are 2.7.x version of the library, such as using the Configparser library, in the 2.6 repository does not support the configuration items without value values, need to upgrade to more than 2.7 of the library line , try upgrading Python to version 2.7.x this time, as recorded here.

First, upgrade Python 2.7. Version 10

1. Prepare the installation package, the system is minimized installation

# Download and install dependencies related packages
[[email protected] ~]# Yum install vim gcc make wget-y[[email protected] ~]# yum install openssl-devel zlib-devel Readlin E-devel sqlite-devel-y
# download [[email protected] ~]# CD/USR/LOCAL/SRC
[[email protected] ~]# wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz# unzip [[email protected] ~]# Tar- ZXVF Python-2.7.10.tgz[[email protected] ~]# lsPython-2.7.10 python-2.7.10.tgz

2. Compiling the configuration installation

[Email protected] ~]# CD Python-2.7.10[[email protected] python-2.7.10]#./configure--enable-shared-- Enable-loadable-sqlite-extensions     --prefix=/usr/local/python27--with-zlib--with-ssl[[email protected] python-2.7.10]# vim./modules/setup    # Find the following line, remove the comment #zlib zlibmodule.c-i$ (prefix)/include-l$ (exec_prefix)/lib- Lz[[email protected] python-2.7.10]# make && make install

3. View Python version information

[[email protected] python-2.7.10]# Python-vpython 2.6.6# version is still 2.6.6

4. Replace the old version with python2.7

[[email protected] python-2.7.10]# cd/usr/bin/[[email protected] bin]# ls python*   -L # old Python version information-rwxr-xr-x. 2 Roo T root 4864 February  pythonlrwxrwxrwx. 1 root root    6 October 18:38 python2-python-rwxr-xr-x. 2 Root Roo T 4864 February  python2.6
[Email protected] bin]# mv/usr/bin/python/usr/bin/python2.6.6[[email protected] bin]# ln-s/usr/local/python27/bin/ Python2.7/usr/bin/python
[[email protected] bin]# ls python*-llrwxrwxrwx. 1 root root   33 October 00:01 python-/usr/local/python27/bin/python2.7lrwxrwxrwx. 1 root root    6 October 18:38 p Ython2, Python-rwxr-xr-x. 2 root root 4864 February  python2.6-rwxr-xr-x. 2 root root 4864 February  python2.6.6

5. Re-verify Python version information

[Email protected] bin]# Python-vpython 2.7.10

As you can see, the Python version that the system recognizes is already Python 2.7.10

To perform the python-v problems encountered:

Python:error while loading shared libraries:libpython2.7.so.1.0:cannot open Shared object file:no such file or Directo ry# reason: The Linux system does not add the/usr/local/python27/lib path to the dynamic library search path by default

Solve:

[[email protected] ~]# vim/etc/ld.so.conf# Add the following line/usr/local/python27/lib[[email protected] ~]# ldconfig  # Make the newly added path take effect

Second, to solve the Yum compatibility problem

Because Yum is not compatible with Python 2.7, Yum does not work properly and we need to specify Yum python as 2.6.

1. Problems with Yum after upgrading Python

[email protected] bin]# Yum There is a problem importing one of the Python modulesrequired to run yum. The error leading to this problem Was:no module named Yum .....

2. Edit the Yum configuration file

[[email protected] bin]# vim/usr/bin/yum#!/usr/bin/python# first line modified to python2.6.6#!/usr/bin/python2.6.6

3. Verifying Yum Problem resolution

[email protected] bin]# yum repolistloaded plugins:fastestmirrorloading mirror speeds from cached hostfile .... ..

Third, after upgrading Python, install the PIP tool

1. Download and install

[[email protected] ~]# wget https://bootstrap.pypa.io/get-pip.py[[email protected] ~]# python get-pip.py

2. Setting up a soft connection

[Email protected] ~]# ln-s/USR/LOCAL/PYTHON27/BIN/PIP2.7/USR/BIN/PIP

Iv. installation of Ipython
[[Email protected] ~]# pip install ipython==1.2.1[[email protected] ~]# ln-s/USR/LOCAL/PYTHON27/BIN/IPYTHON/USR/BIN/IP Ython

Reference Links:
Http://www.jianshu.com/p/7d7c5cf267f4
http://xitongjiagoushi.blog.51cto.com/9975742/1681983/

----------This article ends----------

Upgrade Python 2.6.6 system to version 2.7.10

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.