Ubuntu 12.04 LTS Installation python2.7

Source: Internet
Author: User

The vast majority of Linux distribution have built-in Python, and we can see it just by breaking into Python under the Liunx command line, but the version is a little bit less than we want, such as:

1. Download python

When downloading Python to http://www.python.org/download/it may be that the connection is not open, so add some/////////, like http://www.python.org/////, in front of the download. download/So, after a two-minute suspension can be opened, find the Linux we want to the next version of the Python, see the following version:

There are two types of Linux platforms,

  • Python 2.7 Compressed Source tarball (for Linux, Unix or OS X)

    And

  • Python 2.7 bzipped Source tarball (for Linux, Unix or OS X, more compressed)

  • The second kind of compression is better, in Linux with bzip2 compressed files relatively high, the file name is generally *.tar.bz2,

    But the second version of the above http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2 this is version 2.7, is not what I want, the connection in the 2.7 to 2.6 can be down to the version you want to install.

    Linux download installed source files are generally used in/usr/local/src/, SRC is the source of the abbreviation, enter the directory, with wget download the line:

    This will enable the version of Linux we want to download to this machine.

    2. Decompression

    The downloaded package can be decompressed using the tar command, such as:

    3. Compiling and installing

    Linux generally installs the user installs the software to the/usr/local/xxx/, uses the Configure and make, makes installs these several commands to complete the compilation and the installation,--prefix specifies to install the destination directory, as follows:

    1. Enter the python-2.6 folder
    2,./configure--prefix=/usr/local/python-2.6
    3. Make
    4. Make install

    4. Detecting and setting environment variables

    After the installation, we entered Python on the Linux command line, and executed the previous system's 2.4 version, which is related to the environment variables of the system.

    Enter the/usr/bin/folder to see the following files: Python, Python2, pthon2.4, such as:

    If we use the absolute path to execute the 2.6 version we just installed, we will run version 2.6, such as:

    Switch to this directory, also found the same as the/usr/bin/directory, the same Python file,

    Use Path= "$PATH":/usr/local/python-2.6/bin Add the directory to the Linux environment variable, such as:

    At this point in the command line to enter Python, the system is still performing version 2.4, because the system first searched for/usr/bin/inside the python, but the input python2.6 has executed 2.6 version of the, such as:

    We delete the Python file inside the/usr/bin/and then create a 2.6 symbolic link in that directory to let the system execute the 2.6 version we want, as follows:

    1, cd/usr/bin/
    2. Rm-rf python
    3, Ln-s/usr/local/python-2.6/bin/python./python

    Let's take a look at the files in the/usr/bin/directory and enter Python to perform the version we installed, such as:

Ubuntu 12.04 lts installation python2.7

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.