(第三步)pip换源(macOS版)
一. pip简介
问: 什么是pip?
答: pip可以理解为python的"应用商店", 在里面可以一键安装python的"应用程序"
二. pip换源
问: pip为什么要换源?
答: pip默认要去国外的网站下载, 下载速度比较慢, 好在国内有数个公用同步源, 我们可以把pip设置为国内源, 从而加快下载速度
1. 国内pip镜像
阿里云 https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) https://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple/
2. macOS下pip换源
我们打开启动台
, 点击其他
, 选择终端
并打开
- 打开终端后, 输入如下代码跳转目录至home
cd ~
-
创建
.pip
文件夹mkdir .pip
- 进入.pip文件夹
cd .pip
-
打开配置文件
vim pip.conf
-
回车后会进入一个编辑器,可以在里面输入配置信息
按下i键,进入insert模式
在这里我们输入如下代码:
[global] index-url=http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com
输入完成后我们按
{ESC}
键退出insert模式, 然后按{:}
键,输入{wq!}
, 按{回车}
键退出至此, pip换源完成