MAC OS builds Python development environment __python

Source: Internet
Author: User

Jane Book Wwwwei
Reprint please indicate original source, thank you. Preface

Recently looking at some of the content of machine learning, which a large number of code needs Python's operating environment, so built a python development environment, here recorded, easy to learn. Install Python There are two main ways to install Python under Mac OS: I. Homebrew

Using homebrew to install Python, enter the following command in the direct terminal:

Brew Install Python

If there is a problem with the permissions, please add sudo
If you need to install the Python 3.X version, you can enter the following command directly:

Brew Install Python3
two. Download and install the website

Visit Python's official website https://www.python.org/downloads, download and install the Python installation package, click Install. Verify that the installation was successful

The terminal enters the following command to view the Python installation location

which Python

The terminal enters the following command to view the current version of Python

Python--version

The terminal enters the Python interactive mode by entering the following command

Python
a very important question. Mac OS itself is already with Python, version 2.7.X, this python is primarily used to support system files and Xcode, so it's best not to affect this part when installing a new Python version.

Here is a very disturbing problem, we follow the above steps to install the Python version we need, we usually choose to install the Python 3.X version , after the installation, we enter the following command

Python--version

Or

Python

The discovery is still in the 2.7.X version of Python, because we use the Python command, the system will still invoke the default Python version (that is, the system version), and many tutorials on the web will allow us to modify the configuration file or $ The path variable switches the default Python version of the system to the version we installed , but the personal feeling is not very necessary, after all, the system can not change the best not to change.

Python command

So we chose a simpler way to do that when we needed to use the Python version we had installed (that is, 3 that was previously installed.) x version), use Python3 directly as a command. The same command is:
The terminal enters the following command to view the Python installation location

Which Python3

The terminal enters the following command to view the current version of Python

Python3--version

The terminal enters the Python interactive mode by entering the following command

Python3

Python3 command

Install the Python Package management tool PIP

The current Python3 has actually integrated the PIP, so no need to reinstall, if the previous version, you can Baidu Pip related installation methods, relatively simple, here no longer repeat.

A point to note, as with the above sermon, because the Python version of the system is in parallel, we need to replace the PIP command with the PIP3 command when using the PIP .

The introduction to PIP can refer to the Python Package management tool--PIP

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.