Python Basics-mac How to harness Python2 and Python3

Source: Internet
Author: User

I heard that recently Python has been included in the curriculum of primary school students, as a senior technical people, will not write Python, is simply anxious, probably this is called midlife crisis, then, since the pupils can learn, put down the posture, also to learn to write it, after all, there are skills can also beg mouth food.

Hey, feed the dog.

Python installation

Python official website: https://www.python.org/

Python Document: https://www.python.org/doc/

The following are the installation packages for each platform:

Choose oneself to install the platform, I am also silly, do not know the Mac comes with Python2.7, so installed again Python3.6, then found incredibly can be perfectly compatible,

Installing Python3

Mac Brew really is also quite easy to use, using homebrew installation, convenient and quick management, Bang Bang

brew install python3

After installing the check whether the installation is successful, enter Python3 to see if you can enter the Python3 command line, you can see the version of the Python3 I installed here is 3.6.5

$python 3

Python 3.6.5 (default, APR 2018, 14:23:58)

[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on Darwin

Type "Help", "copyright", "credits" or "license" for more information.

>>>

So how to compatible with Python2, input python2, into the Python2 command line, quite simple have wood ~

$python 2

Python 2.7.15 (default, May 1 2018, 16:44:08)

[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on Darwin

Type "Help", "copyright", "credits" or "license" for more information.

>>>

You can switch at random, like the Devil's pace ~ ~

Similarly, to use Python's Pip and other tools, only need to distinguish between PIP2 and PIP3 can be solved perfectly.

$pip 3

Usage:

PIP3 <command> [Options]

The Windows version can refer to the following link https://www.cnblogs.com/yyds/p/6080826.html, a bit more troublesome than Mac is to configure environment variables.

Python Basics-mac How to harness Python2 and Python3

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.