zoukankan      html  css  js  c++  java
  • 安装pip的三种方式(老是忘)

    避免每次去百度,浪费时间

    1.脚本安装

    这个目前对我来说最简单!

    通过脚本的方式可以保证都能够安装到最新版本的pip,同时操作简单。
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

    python get-pip.py


    2.源码包安装

    下载地址:https://pypi.org/search/?q=pip
    wget --no-check-certific ate https://pypi.python.org/packages/source/p/pip/pip-10.0.1.tar.gz >>/dev/null
    tar -zvxf pip-10.0.1.tar.gz >> /dev/null
    cd pip.10.0.1
    python3 setup.py build
    python3 setup.py install
    注意,这里是安装到python3中,默认是安装到python所链接的具体版本中。

    3.python安装

    这种方式,直接通过python安装,与脚本安装类似,但是这个安装的是当前python版本所以依赖的pip,可能版本较低,因为内置python版本并不高。
    yum upgrade python-setuptools
    yum install python-pip

    另外:有一回在手机上执行curl命令报错,原因:手机锁屏后,网络断开了(亮屏后就好了)

    magongchengdeiPhone:~ root# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
    curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to bootstrap.pypa.io:443

    ------------------------------------------------ 安装时遇到的其他问题 -----------------------------------------------

    1、pip install 时提示没有install指令,查看pip的版本pip -v报错,并出现:C: strawberryperlinpip

    原因:

    • 因为电脑上安装了 Perl 软件,该软件也是pip环境变量,会造成使用Python 命令没办法解析

    解决方法:

    • 需要添加Python的安装路径和Python的scripts 路径为环境变量(两个都必须要)
    • 注意:这两个环境变量需要在下面两个环境变量的上面

    2、pip install 太慢

    临时使用:

    可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

    例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent,这样就会从清华这边的镜像去安装gevent库。

    永久修改,一劳永逸:

    linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:

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

    根据官方文档(https://pip.pypa.io/en/stable/user_guide/),Windows上的配置文件为%APPDATA%pippip.ini。

     进入了C:UsersAdministratorAppDataRoaming
    新建一个文件夹,重命名为pip,然后新建一个pip.ini文件

    新建一个cmd(要退出原先的cmd,命令环境不会实时更新),重新执行安装就很快了

    打开,写入如下配置:

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

    新建一个cmd(要退出原先的cmd,命令环境不会实时更新),重新执行安装就很快了

  • 相关阅读:
    Chapter 03Using SingleRow Functions to Customize Output(03)
    Chapter 03Using SingleRow Functions to Customize Output(01)
    Chapter 04Using Conversion Functions and Conditional ExpressionsNesting Functions
    Chapter 04Using Conversion Functions and Conditional ExpressionsGeneral Functions
    Chapter 11Creating Other Schema Objects Index
    传奇程序员John Carmack 访谈实录 (zz.is2120)
    保持简单纪念丹尼斯里奇(Dennis Ritchie) (zz.is2120.BG57IV3)
    王江民:传奇一生 (zz.is2120)
    2011台湾游日月潭
    2011台湾游星云大师的佛光寺
  • 原文地址:https://www.cnblogs.com/Denny_Yang/p/15039725.html
Copyright © 2011-2022 走看看