zoukankan      html  css  js  c++  java
  • mac os下切换pip3国内源并安装requests库

       

    在使用Python的时候,经常会用到pip来安装模块,但是默认的下载源实在是特别慢,经常install的时候还会因为速度的原因直接报错,因此我们可以选择将下载源更改为国内的,这样就可以提高我们的下载速度了。

        • 国内的知名下载源
        • 阿里云 :http://mirrors.aliyun.com/pypi/simple/
          中国科学技术大学:https://pypi.mirrors.ustc.edu.cn/simple/
          清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
          豆瓣:http://pypi.douban.com/simple/
          

            在mac终端下运行:

        • cd ~
          mkdir .pip
          touch pip.conf 		创建pip.conf文件
          

            然后用vi命令:

        • vi pip.conf
          

            输入以下内容:

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

            然后就可以使用pip了,下载真等快许多!

        •  例如安装:requests 库
        • 直接命令:
          pip3 install requests 
          

            当然可以临时换源:

      • pip3 install requests -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
        

          

  • 相关阅读:
    python中文编码
    Python习题纠错1
    Python中的变量
    Python之注释
    python初步学习
    java输入数据并排序
    五月最后一天
    @component注解
    多线程回顾
    赖床分子想改变--
  • 原文地址:https://www.cnblogs.com/68xi/p/11713651.html
Copyright © 2011-2022 走看看