pip源配置

pip国内的一些镜像

阿里云:http://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/
中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/simple/

  • 临时使用
    可以在使用pip的时候在后面加上-i参数,指定pip源
#pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
  • 永久修改
  • linux
修改 ~/.pip/pip.conf (没有就创建一个)
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
  • windows
直接在user目录中创建一个pip目录,如C:\Users\user\AppData\Roaming\pip,新建文件pip.ini,内容如下
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
  • 常用命令
# pip命令使用格式: pip [选项] [要操作的包名]
# pip命令在控制台执行, 以下命令以django包举例

# pip安装包/模块
$ pip install django   # 此命令表示安装django
# pip下载包/模块
$ pip download django  # 用的较少
# pip卸载包/模块
$ pip uninstall django
# 查看已经安装的包/模块
$ pip list
# 查看已经安装的包/模块的信息
$ pip show django
# 检查包的依赖
$ pip check django
# ====================================
# pip更新所有包
# 查看可更新包:
$ pip list  --outdated --format=columns
# 批量下载并更新:
$ pip install pip-review
$ pip-review --local --interactive

posted on   何苦->  阅读(1801)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示