PyPi镜像配置

2018-07-28  本文已影响0人  user0650

简介

高墙内PyPi下载包时很慢,可以配置为国内镜像提速。

配置方式

PyPi镜像地址有多种配置方式

以上几种方式中,配置文件内容一样,如:

[global]
index-url=http://mirrors.aliyun.com/pypi/simple

其他镜像

上例用了阿里云的镜像地址,除此,还有其他的镜像地址可选

即使配置了pip国内镜像,有些包安装过程中还是会卡住,因为自动装一些其他依赖时又会走python自带的源。

解决方法是修改./lib/python2.7/site-packages/setuptools/package_index.py:

搜索 PackageIndex,修改如下:

class PackageIndex(Environment):
    """A distribution index that scans web pages for download URLs"""

    def __init__(
            #self, index_url="https://pypi.org/simple/", hosts=('*',),
            self, index_url="http://mirrors.aliyun.com/pypi/simple", hosts=('*',),
            ca_bundle=None, verify_ssl=True, *args, **kw
    ):
        Environment.__init__(self, *args, **kw)
        index_url = "http://mirrors.aliyun.com/pypi/simple"
        self.index_url = index_url + "/" [:not index_url.endswith('/')]
上一篇 下一篇

猜你喜欢

热点阅读