ubuntu20.04pip换源
时间: 2023-11-11 12:00:40 浏览: 262
好的,针对您的问题,可以按照以下步骤更换Ubuntu 20.04的pip源:
1. 打开终端,输入以下命令备份原有的pip源:
```
sudo cp /etc/apt/sources.list.d/official-package-repositories.list /etc/apt/sources.list.d/official-package-repositories.list.bak
```
2. 编辑pip源文件,输入以下命令:
```
sudo gedit /etc/apt/sources.list.d/official-package-repositories.list
```
3. 将文件中的内容替换为以下内容:
```
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
```
4. 保存并退出文件。
5. 更新源列表,输入以下命令:
```
sudo apt-get update
```
6. 更新pip,输入以下命令:
```
sudo apt-get install python3-pip
```
7. 验证pip源是否更换成功,输入以下命令:
```
pip config list
```
如果输出结果中的index-url为https://mirrors.tuna.tsinghua.edu.*** 如何编辑pip源文件?
3. 如何验证pip源是否更换成功?
阅读全文