Python PIP 使用国内镜像

Python PIP 使用国内镜像


由于直接使用 pip 安装第三方包时,默认是从国外的路径进行下载的,下载速度比较慢,为了解决这个问题,我们需要把下载路径更换为国内镜像;

1.临时变更

在使用pip安装第三方包时,增加参数:-i https://pypi.tuna.tsinghua.edu.cn/simple(这是清华镜像)
举例:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas

2. 永久变更

windows系统:在user目录中创建一个pip目录,在目录中新建文件pip.ini,写入以下内容:

[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

Linux系统:修改 ~/.pip/pip.conf 的内容为:

[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

没有的话,就创建一个文件夹及文件,文件夹要加点,表示是隐藏文件夹。

3.镜像地址

上述变更中,镜像地址可以更改为以下任意地址:

  • 清华https://pypi.tuna.tsinghua.edu.cn/simple/
  • 阿里云https://mirrors.aliyun.com/pypi/simple/
  • 中国科技大学https://pypi.mirrors.ustc.edu.cn/simple/
  • 华中理工大学https://pypi.hustunique.com/
  • 山东理工大学https://pypi.sdutlinux.org/
  • 豆瓣https://pypi.douban.com/simple/
  • 4
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
使用清华镜像源安装Python包,你可以使用临时使用或永久配置的方法。 临时使用的方法是在下载某一个包时使用清华镜像源。你可以使用以下命令来安装包: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 包名 其中,包名是你需要下载的包的名称。例如,如果你想下载torch包,可以使用以下命令: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch \[1\] 如果你还未安装pip,可以使用以下方法来安装: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py sudo python get-pip.py \[2\] 如果你想永久配置使用清华镜像源,可以执行以下命令: pip3 install pip -U pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 其中,"pip install pip -U" 是用于执行升级pip的命令。\[3\]这样,你就可以使用清华镜像源来安装Python包了。 #### 引用[.reference_title] - *1* *3* [【Pythonpip配置清华镜像源](https://blog.csdn.net/yyj3900636/article/details/122744249)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Python中用pip安装其他库以及使用清华镜像下载](https://blog.csdn.net/lijuncheng555/article/details/130841551)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

这么神奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值