One of the python development environments in Linux-installing Python

Source: Internet
Author: User

The vast majority of Linux distribution has built-in Python installed. We only need to input python in the liunx command line, but the version is a bit low, not what we want, such:

1. Download Python

To begin:

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 type is better compression. in Linux, Bzip2 is used to compress a large number of files. The file name is generally * .tar.bz2,

    However, in the second version above.

     

    Download and install the source code file in Linux is generally used to put in/usr/local/src/. SRC is the abbreviation of source. Enter this directory and download it with wget:

    In this way, we can download the desired Linux version to the local machine.

     

    2. Extract

    Run the tar command to decompress the downloaded package, for example:

     

    3. Compile and install

    In Linux, the software installed by the user is usually installed in/usr/local/XXX/. You can compile and install the software by using the configure, make, and make install commands, -- prefix specifies the target directory to be installed, as follows:

    1 , Go to Python - 2 . 6 folder
    2 ,. / Configure -- Prefix =/ USR / Local / Python - 2.6
    3 , Make
    4 , Make install

     

     

    4. Check and set Environment Variables

    After the installation is complete, we enter python in the Linux Command Line. The execution is still the 2.4 version that comes with the system. This is related to the environment variables of the system.

    The/usr/bin/folder contains the following files: Python, python2, and pthon2.4, for example:

    If we use the absolute path to execute the version 2.6 We just installed, we will run version 2.6, for example:

    Switch to this directory, and you will find that there are Python files in the same directory as/usr/bin,

    Use Path = "$ path":/usr/local/Python-2.6/bin to add the directory to the Linux environment variable, for example:

    Now input python in the command line, and the system still runs version 2.4, because the system first finds python in/usr/bin/, but the input of python2.6 has already executed version 2.6, for example:

    Delete the python file in/usr/bin/, and then create a symbolic link of 2.6 in the directory so that the system can execute the version 2.6 we want, as shown below:

    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. Input python to execute the installed version, for example:

     

     

  • 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.