【Python学习】pypi 软件源-pip

国内源:

anaconda配置镜像

Mac and Linux

1
2
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

 Windows

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

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

pip配置镜像 

Linux

修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:

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

 Windows

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

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

 请注意:一定是在你个人用户文件夹下先建立pip文件夹,在建立pip.ini文件,不是直接把pip.ini文件放在C:\Users\xx\下

pip临时镜像

临时使用:

可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent,这样就会从清华这边的镜像去安装gevent库。

当遇到pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Read timed out.

比如我使用   :easy_install pip  就会出现这个超时,建议更换成豆瓣源使用   -i https://pypi.doubanio.com/simple

pypi 软件源
如何使用?
pip install -i http://xxxxxx --trusted-host xxxxxxx PACKAGE1 PACKAGE2 ...

或者修改默认配置, 编辑 ~/.pip/pip.conf
[global]

# 从官方源 https://pypi.python.org 同步, 10分钟同步一次
index-url = http://xxxxxx

# 内部私有pypi服务
extra-index-url = http://xxxxxx

[install]
trusted-host = xxxxxx

[list]

# 解决pip list时显示警告问题

format=columns

如果你想上传包到内部pypi服务
pip install pypi-uploader
pypiupload packages ${package_path} -i http://xxxxxx
View Code
posted @ 2020-04-10 12:57  gtea  阅读(247)  评论(0编辑  收藏  举报