pip 换国内源

pip源替换

pip源

pip源我主要使用以下几个:

  1. 豆瓣:http://pypi.douban.com/simple/
  2. 清华:https://pypi.tuna.tsinghua.edu.cn/simple
  3. 阿里云: http://mirrors.aliyun.com/pypi/simple/
  4. 中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
  5. 中国科学技术大学: http://pypi.mirrors.ustc.edu.cn/simple/

使用方法

    1. 临时使用
      如果只是临时使用,可以使用-i 加源的方式,如: pip install gevent -i https://pypi.tuna.tsinghua.edu.cn/simple
      注意:如果是http方式的pip源,默认是不安全的,需要增加--trusted-host选项,如pip install paramiko -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
    2. 永久更改
      如果希望永久更改,则需要修改配置文。
      • linux修改配置文
        修改 ~/.pip/pip.conf配置文,没有就创建一个,修改 index-url至你需要的pip源,内容如下:

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

        http方式的配置文如下:

        [global]
        index-url = http://pypi.douban.com/simple
        [install]
        trusted-host=pypi.douban.com
      • windows修改配置文
        直接在user目录中创建一个pip目录,如:C:\Users\watson\pip,新建文件pip.ini,内容如下:

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

        其中index-url就是你选择的pip源
        http方式的配置文和linux下的配置文相同。

posted @ 2020-05-14 11:48  丿好久不见丶  阅读(124)  评论(0编辑  收藏  举报