使用pypi安装包的时候报错【网络不可达】
笔者在使用pypi工具进行python包管理的时候,偶尔会出现如下报错:
~$ pip install casadi
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fb585d10790>: Failed to establish a new connection: [Errno 101] 网络不可达')': /simple/casadi/
![Image](https://img-blog.csdnimg.cn/direct/2f5f212182924df4867d8897fbbe2764.png)
这种情况一般是我们国内的网络不好,不能直连,所以我们可以在pip
语句后面指定一个国内的镜像源。
常用的镜像源有:
镜像源 | 地址 |
---|---|
清华源 | https://pypi.tuna.tsinghua.edu.cn/simple |
阿里源 | https://mirrors.aliyun.com/pypi/simple/ |
中科大源 | https://pypi.mirrors.ustc.edu.cn/simple/ |
腾讯源 | https://mirrors.cloud.tencent.com/pypi/simple |
我们可以使用-i
来指定使用的镜像源,比如:
pip install casadi -i https://pypi.tuna.tsinghua.edu.cn/simple
这样就能解决网络不好的问题,顺利安装了。