PyPI镜像使用指导

须弥零一

共 1748字,需浏览 4分钟

 · 2021-08-04

须弥零一

Python 包索引(The Python Package Index,PyPI)是 Python 编程语言的软件存储库。官网站点:https://pypi.org/

但是国内由于各种各样的原因,可能经常会因为网络问题而没法按照预期来安装我们期望的软件包。这个时候就可以使用国内的PyPI镜像来安装了。

下面以清华大学开源软件镜像站的PyPI镜像站为例来说明:

临时使用

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

注意: simple 不能少, 是 https 而不是 http

设为默认

升级 pip 到最新的版本 (>=10.0.0) 后进行配置:

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

如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:

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

使用如下方法也可以起到永久修改的目的。

Linux环境 修改 ~/.pip/pip.conf (没有就创建一个)

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

Windows环境 windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini

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


国内镜像

豆瓣:http://pypi.douban.com/simple阿里云:http://mirrors.aliyun.com/pypi/simple/中科大:http://pypi.mirrors.ustc.edu.cn/simple/清华大学:https://pypi.tuna.tsinghua.edu.cn/simple网易:https://mirrors.163.com/pypi/simple/

可能出现的问题处理

报错内容

pip install mysql-pythonCollecting mysql-python  The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host pypi.douban.com'.  Could not find a version that satisfies the requirement mysql-python (from versions: )No matching distribution found for mysql-python

解决办法

编辑 vim .pip/pip.conf

[install]trusted-host = pypi.tuna.tsinghua.edu.cn

原文:https://www.jeremysong.cn/cn/pypi-mirrors/

---- END ----



欢迎关注我的公众号“须弥零一”,更多技术文章第一时间推送。

浏览 70
点赞
评论
收藏
分享

手机扫一扫分享

举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

举报