pip install 使用清华源
时间: 2024-09-06 08:04:41 浏览: 25
`pip install` 是Python包管理工具,用于安装、升级和卸载Python软件包。如果你想要通过清华大学的镜像源来安装Python包,首先你需要配置pip使用这个镜像。以下是步骤:
1. 首先,需要确保你的系统中已经安装了pip。如果没有,你可以通过Python自带的工具来安装它:
```
python -m ensurepip --default-pip
```
2. 找到清华大学的PyPI镜像地址,通常是 `https://pypi.tuna.tsinghua.edu.cn/simple/` 或 `http://pypi.mirrors.ustc.edu.cn/simple/`。
3. 创建pip配置文件(如果还没有的话),通常位于~/.pip下的pip.conf或piprc(Windows用户在%USERPROFILE%\.pip\pip.ini):
```bash
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host = pypi.tuna.tsinghua.edu.cn
```
或者
```
[global]
index-url = http://pypi.mirrors.ustc.edu.cn/simple/
trusted-host = pypi.mirrors.ustc.edu.cn
```
4. 现在可以使用配置后的pip安装包了,例如你想安装requests库:
```
pip install requests
```