一. 基于Mac自带的Python2使用pip工具
- Mac自带Python2,因此,直接在Mac上输入python命令,操作的都是Python2.
- Mac虽然自带Python2,但是并没有自带对应的pip工具,因此,在使用pip工具之前,需要我们自行安装,命令:
sudo easy_install pip
1.1 使用pip安装python模块
以安装requests为例,命令:
pip install requests
1.2 使用pip工具卸载python模块
以卸载requests为例,命令:
pip uninstall requests
1.3 使用pip查看已安装的模块
以查看requests为例,命令:
pip show --files requests
二. 基于自行安装的Python3使用pip工具
- 切记,如果你自行安装了Python3,那么就不用再安装pip工具了,Python3的安装包中自带有pip工具;
- 由于Mac自带Python2,在使用pip工具为Python3安装模块时,必须显式指明pip针对的Python版本,方式如下:
以安装requests为例,命令:
pip3 install requests
与Python2的区别就是,pip命令改为pip3。