First lesson: Python Installation

Source: Internet
Author: User

Python is cross-platform and can run on Windows, Macs, and various Linux/unix systems. Write a Python program on Windows and put it on Linux to run it.

Installing Python 2.7

Currently, Python has two versions, one is version 2.x, the other is 3.x, and these two versions are incompatible. Since the 2.x version is currently widely available, we are basing it on Python version 2.7. The following describes the Python installation on each platform, respectively.

Install Python on Linux

In general, the Linux system is preloaded with the Python environment, you can directly run the Python check, if the version is relatively low, you can consider the next officer network download the new source package, unpack the package to the corresponding path, enter the path, compile and install. The steps are as follows:

wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz

TAR-XVF python-2.7.14.tgz

CD Python-2.7.14

./configure

Make

Make install

Now that the installation is complete, you can see if the installation was successful by running the Python command.

Install Python on your Mac

If you are using a Mac and the system is OS X 10.8~10.10, then the Python version that comes with the system is 2.7. To install the latest Python 3.x, there are two methods:

Method One: Download the Python 3.6 installer from the Python website, double click to run and install;

Method Two: If homebrew is installed, it can be installed directly from the command brew install Python.

Install Python on Windows

First, depending on your version of Windows (64-bit or 32-bit), download the 64-bit installer or 32-bit installer for Python 2.7 from the official Python website, and then run the downloaded EXE installation package, all with the default.

Test run Python

After the installation is successful, open a command Prompt window, after typing python, if the following occurs:

' Python ' is not an internal or external command, nor is it a running program or batch file.

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/A7/4C/wKioL1nkpi2xqnKeAACPf3msOwk695.jpg-wh_500x0-wm_ 3-wmp_4-s_683744896.jpg "style=" Float:none; "title=" capture. JPG "alt=" Wkiol1nkpi2xqnkeaacpf3msowk695.jpg-wh_50 "/>

This is because Windows is based on a path set the path of the environment variable to find the Python.exe , if not found, will be an error. Here we need to set the environment variables in the system properties,

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/A7/4D/wKioL1nkr6bQP-W8AAC7M6nFPtI609.png-wh_500x0-wm_ 3-wmp_4-s_3508856138.png "title=" Qq20171016211935.png "alt=" Wkiol1nkr6bqp-w8aac7m6nfpti609.png-wh_50 "/>

Once setup is complete, running Python again will appear as

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/08/9C/wKiom1nkqOPDAT6fAACe4rJas9U370.jpg-wh_500x0-wm_ 3-wmp_4-s_2329173970.jpg "title=" 1.JPG "style=" Float:none; alt= "Wkiom1nkqopdat6faace4rjas9u370.jpg-wh_50"/>

See the above screen, it shows that Python installation success!.

Let's try to print out the specified text using Python, you can use the print statement to enclose the text you want to print in single or double quotation marks, but not with single and double quotes, and then output Hello World as an example. Of course you can also assign a value to variable a, and then output a directly. Effect

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/08/9E/wKiom1nktSWgO_gqAAAwfUg-IB8304.png-wh_500x0-wm_ 3-wmp_4-s_1764397869.png "title=" Qq20171016213243.png "alt=" Wkiom1nktswgo_gqaaawfug-ib8304.png-wh_50 "/>

This article is from the "Dreamscape" blog, make sure to keep this source http://dyqd2011.blog.51cto.com/3201444/1973026

First lesson: Python Installation

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.