Home >Backend Development >Python Tutorial >How to install modules in python on mac

How to install modules in python on mac

(*-*)浩
(*-*)浩Original
2019-06-29 12:14:435703browse

Mac comes with Python2, so if you enter the python command directly on the Mac, you will operate Python2. Although Mac comes with Python2, it does not come with the corresponding pip tool. Therefore, before using the pip tool, we need to Install yourself

How to install modules in python on mac

First, install pip. Then use pip to install the python library. The system comes with easy_install, easy to install pip (recommended learning: Python video tutorial)

 $ sudo easy_install -g pip

Use pip to install the python module

to Take the installation of requests as an example, command:

pip install requests

If an error is reported and insufficient permissions are displayed, use the command:

sudo pip install requests

Remember, if you installed Python3 by yourself, there is no need to install pip tool, the Python3 installation package comes with the pip tool;

Since Mac comes with Python2, when using the pip tool to install modules for Python3, you must explicitly specify the Python version for which pip is targeted. As follows:

Take the installation of requests as an example, the command:

pip3 install requests

The difference with Python2 is that the pip command is changed to pip3.

For more Python related technical articles, please visit Python Tutorial column to learn!

The above is the detailed content of How to install modules in python on mac. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn