Python Installation Guide and python3 Program Development Guide

Source: Internet
Author: User

Python Installation Guide and python3 Program Development Guide

Note: My installation environment is centos6.4, a 32-bit system. (The content after # Is the description)

 1. Preparation

Centos comes with python, so you can directly execute python in shell.

You can see the printed information, but the python2.6 version is too old, so you should re-compile a new version of python.

However, it is better not to overwrite the python that comes with the original system to prevent inexplicable system problems. You can compile the new version of python to a specified directory!

 2. Download the installation package

Wget https://www.python.org/ftp/python/2.7.10/Python-2.7.5.tgz

### If an error is reported during download, you can choose to discard the verification option if you need certificate verification;

Decompress:

Tar-zxvf Python-2.7.5.tar.gz ### extract the downloaded file;

3. Install

Switch to the root user (su command)

Cd Python-2.7.5

./Configure -- prefix =/usr/local/python27

If an error is reported, install the corresponding dependency package (use the yum command to install the default dependency file) and continue to execute this command!

Make & make install & make clean

Wait until the installation is complete, and then execute:

/Usr/local/python27/bin/python

We can see that the information printed by python shows that the python version is the new version we have installed!

Now the problem occurs. The version of python is 2.7.5 for the root user. However, the version of python is 2.6.6 for normal users.

The problem was originally found to be "executed by common users/usr/bin/python;

Solution:

You can connect the script to the/usr/bin directory, so that the script can be directly started in shell and executed:

Ln-s/usr/local/python27/bin/python/usr/bin/python27

Then run python27 in shell.

We can see that the printed information is the latest python version installed!

4. Test

Switch to the home Directory, create a new python folder, and create a suffix:. py

And then enter the following code:

#! /Usr/bin/python27

Import platform

Print platform. uname ()

Save the file and exit. After adding the executable permission to the file, run:./file name.

The information is displayed! So far, complete!

I am also a beginner in Python, and I am not very familiar with it. I certainly have some bad ideas. I hope you can give me some advice and I will correct it in time, but please do not add any evil words!Thank you.

If you like this article, leave a comment later.

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.