CentOS Upgrade Python 2.7 and install PIP, Ipython

Source: Internet
Author: User
Tags readline

Https://www.cnblogs.com/technologylife/p/6242115.html

CentOS system is generally installed by default Python2.6.6 version, a lot of software needs more than 2.7, through the package management tool can not install the latest version, through the source code compiled to facilitate the installation of the specified version, only need to replace the following version of the number of the version you want.

1. Installation Steps

Download source code

1 wget http://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz

Unzip the source code in the download directory

1 tar-zxvf Python-2.7.12.tgz

Enter the extracted folder

1 cdPython-2.7.12

Build a folder in/usr/local before compiling python2.7.12 (as a Python installation path to avoid overwriting old versions, old and new versions can coexist)

1 mkdir/usr/local/python2.7.12

You need to install the following dependencies before compiling, otherwise the PIP will go wrong under the installation

1 yum installopenssl openssl-devel zlib-devel gcc  sqlite-devel -y

After installing dependencies, execute the following command

1 vim ./Modules/Setup.dist

Find #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz out the comment and save it (i.e. remove the # number)

Compile the installation in the unzipped directory

12 ./configure --prefix=/usr/local/python2.7.12 --with-zlibmake && make install

The old version is not overwritten at this time, then the original /usr/bin/python link is changed to another name

1 mv/usr/bin/python /usr/bin/python2.6.6

Create a new version of Python's soft link

1 ln-s /usr/local/python2.7.12/bin/python2.7 /usr/bin/python

This time at the command line input
  python
The new version of Python will be displayed.

123 Python 2.7.12 (default, Oct 13 2016, 03:17:14)[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2Type “help”, “copyright”, “credits” or “license” formore information.
2. Modifying the Yum configuration file

The reason to keep the old version is because Yum relies on Python2.6 to change the Yum configuration file to specify the old Python version.

  vim /usr/bin/yum, the first line is #!/usr/bin/python modified to#!/usr/bin/python2.6.6

3. Install the latest version of PIP
12 wget https://bootstrap.pypa.io/get-pip.pypython get-pip.py

Before the old version of the words are deleted first rm -rf /usr/bin/pip )

1 ln-s /usr/local/python2.7.12/bin/pip2.7 /usr/bin/pip

Look at the PIP version.

1 pip -V

PIP has been installed and can now be used to download and install various packages.

Installing Ipython

Installing using the Pip method

1 pip installipython

  Installing the ReadLine expansion module

123 yum install readline-develyum install patch pip install readline

You need to add the Ipython path soft link to the/usr/bin directory

1 ln-s /usr/local/python2.7.12/bin/ipython  /usr/bin/ipython

At this point Ipython installation is complete

This article refers to the link: http://blog.fazero.me/2016/10/13/centos-update-python/

CentOS Upgrade Python 2.7 and install PIP, Ipython

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.