Home>Article>Backend Development> How to install modules in python on mac
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
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 visitPython Tutorialcolumn 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!