First Glimpse of Python (iii)--python version upgrade and Ipython installation and use

Source: Internet
Author: User
Tags openssl

using CentOS6.6 X64 system, because the system comes with python version 2.6.6 version is currently commonly used for 2.7 version, so we're going to the system python version to do an upgrade. ipython is an enhanced version of Shell TAB complement, auto indent and so on, more than the default python shell to be a lot more useful. Here's how to upgrade the python pip pip install install ipython, build a simple python environment.

1. Download the installation package on the website:

[[email protected] ~]# cd/usr/local/src[[email protected] src] #wget https://www.python.org/ftp/python/2.7.10/ Python-2.7.10.tgz

2. Unzip, compile, install:

[[Email protected] src]# tar zxf python-2.7.10.tgz[[email protected] src]# CD Python-2.7.10

It is important to note that before compiling the installation, you need to ensure that Openssl-devel,zlib-devel,readline-devel are installed in the system, Sqlite-devel, reasons will be elaborated at the end of the text.

[email protected] python-2.7.10]# Yum install-y openssl-devel zlib-devel readline-devel sqlite-devel[[email protected] python-2.7.10]#./configure--prefix=/usr/local/python2.7.10[[email protected] python-2.7.10]# make && make Install

3. Modify the current Python command version:

after the installation is complete, view the python version:

[Email protected] ~]# Python-vpython 2.6.6

The discovery version does not change, and you need to manually create a soft link:

[Email protected] ~]# rm-f/usr/bin/python

There is no need to worry about accidental deletion, because there is a python2.6 command in the/usr/bin directory:

[Email protected] ~]# Python2.6-vpython 2.6.6

so bold rm-f can. To create a soft link:

[Email protected] ~]# ln-s/usr/local/python2.7.10/bin/python2.7/usr/bin/python

now look at the Python version:

[Email protected] ~]# Python-vpython 2.7.10

after upgrading the version, there are still some cleanup work remaining. Since the yum command only supports the use of python2.6, in order to prevent the Yum command from invalidating, modify the /usr/bin/yum command:

[Email protected] ~]# Vim/usr/bin/yum

The first line of the

#!/usr/bin/python

Revision changed to

#!/usr/bin/python2.6

Save to exit.

4. install pip < Span style= "font-family: ' The song Body '; >:

pip python yum and node. js Npm, believe in contact with python pip to install Ipython pip mounted. Install pip need to first install Setuptools https://pypi.python.org/pypi/setuptools download it yourself):

[Email protected] src]# wget https://pypi.python.org/pypi?:action=show_md5&digest= F72e87f34fbf07f299f6cb46256a0b06[[email protected] src]# tar zxf setuptools-18.1.tar.gz[[email protected] src]# CD Setuptools-18.1[[email protected] setuptools-18.1]# python setup.py install

after the installation succeeds -1 is shown.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/70/F7/wKiom1XB5O7AIPxGAAIItaHnU30501.jpg "title=" Py1.png "alt=" Wkiom1xb5o7aipxgaaiitahnu30501.jpg "/>

Figure -1 setuptools installation succeeded

when finished, install pip(if the download link fails, please visit https://pypi.python.org/pypi/pip to download it yourself):

[Email protected] src]# wget https://pypi.python.org/packages/source/p/pip/pip-7.1.0.tar.gz#md5= D935ee9146074b1d3f26c5f0acfd120e[[email protected] src]# tar zxf pip-7.1.0.tar.gz[[email protected] src]# CD pip-7.1.0[ [email protected] pip-7.1.0]# python setup.py install

after the installation succeeds -2 is shown.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/70/F6/wKiom1XB0RqgNO4oAAIHWkG7et0626.jpg "title=" Py2.png "alt=" Wkiom1xb0rqgno4oaaihwkg7et0626.jpg "/>

Figure -2 pip installation succeeded

The pip file after installation is located in the/usr/local/python2.7.10/bin/directory, creating a soft link for PIP for ease of use :

[Email protected] ~]# ln-s/USR/LOCAL/PYTHON2.7.10/BIN/PIP/USR/BIN/PIP

5. Install ipython:

To install Ipython using the pip command :

[[Email protected] ~]# pip install Ipython

after the installation succeeds -3 is shown.

650) this.width=650; "border=" 0 "width=" 554 "height=" "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/>

Figure -3 Ipython installation succeeded

after the installation is complete, the ipython file is located in the/usr/local/python2.7.10/bin/ directory, for ease of use, to establish a soft link for Ipython:

[Email protected] ~]# ln-s/usr/local/python2.7.10/bin/ipython/usr/bin/ipython[[email protected] ~]# Ipython

Enter the following interactive page,4 , then you can use the ipython TAB Auto- complete function, auto Indent function and similar sorted?? View the features described in this method.

650) this.width=650; "border=" 0 "width=" 553 "height=" [src=]/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/>

Figure -4 Getting started with Ipython


Add:

Finally, if Openssl-devel is not installed in the system when the make && make install Python2.7.10,zlib-devel ,readline-devel,sqlite-devel Four packets will have a separate problem.

if Zlib-devel is not installed , an error of 5 is reported when installing Setuptools , which is runtimeerror:compression requires The (missing) zlib module error:

650) this.width=650; "border=" 0 "width=" 554 "height=" 101 "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/>

Figure -5 missing zlib-devel

if Openssl-devel is not installed , a 6 error is reported when installing Ipythonusing the pip install ipython command , which is Importerror:cannot Import name Httpshandler error:

650) this.width=650; "border=" 0 "width=" 554 "height=" "src=" "/e/u261/themes/default/images/spacer.gif" style= " Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/>

Figure -6 missing openssl-devel

If you do not have readline-devel and sqlite-devel installed, you will find three WARNING in the times whenusing Ipython, and theeffect is Ipython cannot record historical information (which is of course not very significant), while Ipython does not have a color hint,TAB completion and auto Indent function, so Ipython is meaningless,as shown in 7 .

650) this.width=650; "border=" 0 "width=" 554 "height=" 202 "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd; "alt=" spacer.gif "/>

Figure 7 missing readline-devel and sqlite-devel

If you have made && make install Python2.7.10 in the absence of a package, you only need the Yum install package in case of an error, then re-enter Python-2.7.10 directory make && make install will solve the problem, of course, make&& make install the time required for the longer, It is recommended that you confirm the installation of these four packages prior to the make && do install for a successful event.

Finish.


This article is from the "barrel of fake dog excrement" blog, please be sure to keep this source http://xitongjiagoushi.blog.51cto.com/9975742/1681983

First Glimpse of Python (iii)--python version upgrade and Ipython installation use

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.