pip添加镜像源

pip 配置下载镜像源(永久)

ubuntu电脑

  1. 查看电脑上面是否已经存在pip.conf文件
find . -name pip.conf
  1. 进入文件夹或者创建文件夹
mkdir ~/.pip && touch ~/.pip/pip.conf
  1. 修改镜像源
[global] 
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install] 
trusted-host = pypi.tuna.tsinghua.edu.cn
  1. pip 下载
pip install numpy

在这里插入图片描述
现在pip索引是直接在清华源上搜索。

win电脑

方式一:

  1. 进入目录: C:\Users\用户名\pip
  2. 创建 pip.ini文件,并在文件中添加

方式二:
第二种办法就是,按:win+R在输入: %APPDATA% ,跳转到: :“C:\Users\此处是你的计算机用户名\AppData\Roaming”,找的pip文件夹,打开pip.ini文件,并写入下面key。

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

查看pip配置

pip config list

国内镜像源

# 清华源
https://pypi.tuna.tsinghua.edu.cn/simple
# 豆瓣
http://pypi.douban.com/simple/
# 阿里云
http://mirrors.aliyun.com/pypi/simple/
# 腾讯云
 https://mirrors.cloud.tencent.com/pypi/simple

pip 下载镜像源(临时)

pip install numpy -i https://pypi.tuna.tsinghua.edu.cu/simple
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
使用pip添加清华镜像源有两种方式:临时使用和永久配置。 临时使用清华镜像源的方法是在执行pip安装命令的时候指定清华镜像源的URL。例如,要下载名为xxx的包,可以使用以下命令: ``` pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxx ``` 其中,https://pypi.tuna.tsinghua.edu.cn/simple是清华镜像源的URL,xxx是需要下载的包的名字。这种方式只在当前命令中使用清华镜像源,不会对默认服务器配置产生影响。 永久配置清华镜像源的方法有两种。第一种是通过执行以下命令来永久替换服务器为清华镜像源: ``` pip3 install pip -U pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple ``` 其中,"pip install pip -U" 是用于执行升级pip的命令,将pip版本更新到最新。"pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple" 是用于设置全局的index-url,将服务器配置为清华镜像源。这样,在执行pip安装命令时,就会默认使用清华镜像源进行下载。 第二种方法是通过修改pip的配置文件来永久设置清华镜像源。打开用户目录下的pip配置文件(Linux/macOS为~/.pip/pip.conf,Windows为C:\Users\用户名\pip\pip.ini),将以下内容添加到配置文件中: ``` <span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [pip添加清华镜像源](https://blog.csdn.net/eefresher/article/details/89606866)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值