pip更改国内源

默认情况下,pip安装一个工具,是通过使用官方的源(https://pypi.python.org/simple),速度上是一个很大的问题,例如,安装tensorflow,默认第一个下载速度就已经很慢了,几乎要半个小时才能安装。


这里可以通过配置国内源来提速。

永久有效的办法:root用户在根目录下新建.pip目录,在目录中创建文件pip.conf(/root/.pip/pip.conf),配置内容如下,这里使用的清华源,还是挺快的:

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

配置完成,无需任何操作,直接通过pip install即可安装任何想要的工具,再次来对比一下(输入pip install tensorflow之后立马截图就已经是如下图所示的效果)。


不到30秒,全部安装完成。速度惊人。

整个tensorflow的安装过程:

[root@VM_176_170_centos .pip]# pip install tensorflow
Collecting tensorflow
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/69/6d/09d4fbeedbafbc6768a94901f14ace4153adba4c2e2c6e6f2080f4a5d1a7/tensorflow-1.5.0-cp27-cp27mu-manylinux1_x86_64.whl (44.4MB)
    100% |████████████████████████████████| 44.4MB 24kB/s 
Collecting absl-py>=0.1.6 (from tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5f/b8/3dafc45f20a817ab9f042302646bcbe6f7e26e8a760871a85637e53a35ec/absl-py-0.1.10.tar.gz (79kB)
    100% |████████████████████████████████| 81kB 1.5MB/s 
Collecting backports.weakref>=1.0rc1 (from tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/88/ec/f598b633c3d5ffe267aaada57d961c94fdfa183c5c3ebda2b6d151943db6/backports.weakref-1.0.post1-py2.py3-none-any.whl
Requirement already satisfied: wheel in /usr/lib/python2.7/site-packages (from tensorflow)
Collecting numpy>=1.12.1 (from tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/62/5a/6ba7ea4f097343021efd721200126969c603295b1b76c5469795e2f9ea38/numpy-1.14.1-cp27-cp27mu-manylinux1_x86_64.whl (12.1MB)
    100% |████████████████████████████████| 12.1MB 92kB/s 
Collecting tensorflow-tensorboard<1.6.0,>=1.5.0 (from tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cd/ba/d664f7c27c710063b1cdfa0309db8fba98952e3a1ba1991ed98efffe69ed/tensorflow_tensorboard-1.5.1-py2-none-any.whl (3.0MB)
    100% |████████████████████████████████| 3.0MB 364kB/s 
Collecting mock>=2.0.0 (from tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e6/35/f187bdf23be87092bd0f1200d43d23076cee4d0dec109f195173fd3ebc79/mock-2.0.0-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 1.3MB/s 
Collecting enum34>=1.1.6 (from tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl
Collecting protobuf>=3.4.0 (from tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/55/75/dbfc79855b727adf187672d3d184fe70db02101ea54b0307c3025fa57bfb/protobuf-3.5.1-cp27-cp27mu-manylinux1_x86_64.whl (6.4MB)
    100% |████████████████████████████████| 6.4MB 174kB/s 
Collecting six>=1.10.0 (from tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting futures>=3.1.1; python_version < "3" (from tensorflow-tensorboard<1.6.0,>=1.5.0->tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2d/99/b2c4e9d5a30f6471e410a146232b4118e697fa3ffc06d6a65efde84debd0/futures-3.2.0-py2-none-any.whl
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<1.6.0,>=1.5.0->tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6d/7d/488b90f470b96531a3f5788cf12a93332f543dbab13c423a5e7ce96a0493/Markdown-2.6.11-py2.py3-none-any.whl (78kB)
    100% |████████████████████████████████| 81kB 865kB/s 
Collecting bleach==1.5.0 (from tensorflow-tensorboard<1.6.0,>=1.5.0->tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/33/70/86c5fec937ea4964184d4d6c4f0b9551564f821e1c3575907639036d9b90/bleach-1.5.0-py2.py3-none-any.whl
Collecting html5lib==0.9999999 (from tensorflow-tensorboard<1.6.0,>=1.5.0->tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ae/ae/bcb60402c60932b32dfaf19bb53870b29eda2cd17551ba5639219fb5ebf9/html5lib-0.9999999.tar.gz (889kB)
    100% |████████████████████████████████| 890kB 911kB/s 
Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<1.6.0,>=1.5.0->tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
    100% |████████████████████████████████| 327kB 1.4MB/s 
Collecting funcsigs>=1; python_version < "3.3" (from mock>=2.0.0->tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/69/cb/f5be453359271714c01b9bd06126eaf2e368f1fddfff30818754b5ac2328/funcsigs-1.0.2-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock>=2.0.0->tensorflow)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0c/5d/b077dbf309993d52c1d71e6bf6fe443a8029ea215135ebbe0b1b10e7aefc/pbr-3.1.1-py2.py3-none-any.whl (99kB)
    100% |████████████████████████████████| 102kB 1.9MB/s 
Requirement already satisfied: setuptools in /usr/lib/python2.7/site-packages (from protobuf>=3.4.0->tensorflow)
Building wheels for collected packages: absl-py, html5lib
  Running setup.py bdist_wheel for absl-py ... done
  Stored in directory: /root/.cache/pip/wheels/ba/48/c1/6fbcc86ca3f2c54c92b115ab51ebcfb4907d6b96df55b81cea
  Running setup.py bdist_wheel for html5lib ... done
  Stored in directory: /root/.cache/pip/wheels/a8/a9/e6/b7f9d0b18cf4a411d99eaaba3f0e96d2c6c93cb14a73de0ae9
Successfully built absl-py html5lib
Installing collected packages: six, absl-py, backports.weakref, numpy, futures, markdown, html5lib, bleach, werkzeug, protobuf, tensorflow-tensorboard, funcsigs, pbr, mock, enum34, tensorflow
  Found existing installation: six 1.9.0
    Uninstalling six-1.9.0:
      Successfully uninstalled six-1.9.0
Successfully installed absl-py-0.1.10 backports.weakref-1.0.post1 bleach-1.5.0 enum34-1.1.6 funcsigs-1.0.2 futures-3.2.0 html5lib-0.9999999 markdown-2.6.11 mock-2.0.0 numpy-1.14.1 pbr-3.1.1 protobuf-3.5.1 six-1.11.0 tensorflow-1.5.0 tensorflow-tensorboard-1.5.1 werkzeug-0.14.1

如果不配置源,可以在安装的时候通过参数指定也可以达到加速的效果。

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

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luffy5459

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值