您现在的位置是:网站首页> PY&Rust
Python包管理、包的安装源及已安装的包
- PY&Rust
- 2025-08-24
- 1313人已阅读
Python包管理、包的安装源及已安装的包
安装包源
Python包的安装源,可能是由于内容开始是网络地址(http://...)截取后不能换行造成 为避免代码造成手机端排版的混乱,可适当增加文字描述,将代码往后推移
pip install xxxx -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
永久修改(推荐)
方法一:使用 pip 命令配置
# 设置默认源(以清华镜像为例)
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 可选:添加额外源
pip config set global.extra-index-url "<url1> <url2>"
方法二:手动创建配置文件
首先找到配置文件位置:
Windows:C:\Users\你的用户名\pip\pip.ini
Linux/Mac:~/.pip/pip.conf 或 ~/.config/pip/pip.conf
创建或编辑配置文件,添加以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
常用国内镜像源
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple/
豆瓣:https://pypi.douban.com/simple/
中科大:https://pypi.mirrors.ustc.edu.cn/simple/
验证配置是否生效
pip config list
Python查看已安装的包
使用pip list命令
使用conda list(如果你使用 Anaconda 或 Miniconda)
uv的安装
pip install uv
上一篇:Python项目实操笔记
下一篇:Python AI 相关资料