CentOS 6.9
Python 3.4
pip镜像国外的下载速度慢,需要将pip镜像源换成国内镜像
在/home/用户名/目录下新建.pip/pip.conf文件
文件内容如下:
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
pip install get-time
打印的信息中,显示已经换源成功,但是非root用户没有修改文件的权限
[cox@799a3e499eed python2.6]$ pip install get-time
DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
Looking in indexes: http://pypi.douban.com/simple
Collecting get-time
Installing collected packages: get-time
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/lib/python3.4/site-packages/get_time'
Consider using the `--user` option or check the permissions.
切换root用户
su root
pip install get-time
下载成功,但是很慢,并没有使用国内的镜像源
[root@799a3e499eed python2.6]# pip install get-time DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won’t be maintained after March 2019 (cf PEP 429). Collecting get-time Downloading https://files.pythonhosted.org/packages/6c/2c/881da0e98685d2b39596f198eaf11ff6582fde5eb403c52bf3f405a1128f/get-time-0.0.4.tar.gz Building wheels for collected packages: get-time Building wheel for get-time (setup.py) … done Stored in directory: /root/.cache/pip/wheels/6c/9d/4e/58515015fcd0ec032405fd8ce96795aed16458edd1ca793532 Successfully built get-time Installing collected packages: get-time Successfully installed get-time-0.0.4
为什么没有root用户没有使用刚刚配置的国内的镜像源 ???
原来是因为配置的pip.conf文件存在/home/用户名/目录下,这样配置的镜像源只对指定的用户起作用, 使用root权限下载的时候,并不会走pip.conf文件,所以下载很慢
如何配置root用户额镜像源 ???
在~目录下新建.pip/pip.conf文件, 内容同上
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
使用root用户下载