Back
Featured image of post python3|pycharm修改pip获取源链接

python3|pycharm修改pip获取源链接

国内用pip连不上官网安装不了包,修改获取源链接即可。

背景介绍

OS: windows 10

python version: 3.8

python DEV: pycharm 2020.1

no module named ‘requests’

问题描述

当在pycharm下的terminal使用如下命令,会报错:

pip install requests

error:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ProxyError(‘Cannot connect to proxy.’, OSError(0, ‘Error’))': /pypi/simple/requests/

ERROR: Could not find a version that satisfies the requirement requests ERROR: No matching distribution found for requests

Cannot connect to proxy. 反正就是让你连不上,懂的都懂。

解决办法

方法一

  1. 打开pycharm ,file -> settings -> project(name) -> python Interpreter -> add -> manage repositories

  2. 不要点【+】而是【🖊】,因为这里最后只能保存一个。更改为:

https://pypi.tuna.tsinghua.edu.cn/simple

用清华是因为5分钟就同步。

如果用新增,尽管把tuna的挪到前面,但是运行的时候,会自动忽略,只要有官方的存在,就还是走官方的,打个比方就是虽然你后宫佳丽很多,但是翻牌子只能翻一个,虽然你安排了今天清华侍寝,但是皇后正宫地位偷天换日把自己换上来了,而且进了门就不让你出,所以一直连不上。

这里最后只能保存一个

  1. 重启

方法二

由网友提供,在pycharm下的terminal使用如下命令

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

这个就是纯文本化的不用点来点去找来找去改东西,一条梭哈。

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy