提高pip安装组件速度 更换为国内镜像源 |
随着Python的不断发展、Python项目在服务器生产环境中的应用越来越多,但是pip源默认也是国外的,有时候下载速度才10KB 简直不能忍受下,如果想加快pip组件安装速度就需要替换pip源为国内地址进行加速。 创建目录(以清华镜像为例) [root@aliyun home] mkdir -p ~/.pip 创建配置文件: [root@aliyun home] vim ~/.pip/pip.conf [global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple/ [install] trusted-host=https://pypi.tuna.tsinghua.edu.cn 其他国内源地址如下: 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/ 现在使用pip安装组件就可以体会到飞一般的速度了。 如果是临时使用国内地址可以在安装组件的时候加参数-i pip install nose -i http://mirrors.aliyun.com/pypi/simple windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,然后新建文件pip.ini,即 %HOMEPATH%\pip\pip.ini,在pip.ini文件中输入以下内容(以清华镜像为例): 创建pip.ini文件可以用文本编辑器,例如 sublime text3。 pip.ini文件中的内容如下: [global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple/ [install] trusted-host = pypi.tuna.tsinghua.edu.cn 在cmd尝试安装pandas |