zoukankan      html  css  js  c++  java
  • 在centos7.5中解决bash: pip:command not find 问题




    在centos7.5中解决bash: pip:command not find 问题


    [root@localhost ~]# python get-pip.py
    
    Hi there!
    
    The URL you are using to fetch this script has changed, and this one will no
    longer work. Please use get-pip.py from the following URL instead:
    
        https://bootstrap.pypa.io/pip/2.7/get-pip.py
    
    Sorry if this change causes any inconvenience for you!
    
    We don't have a good mechanism to make more gradual changes here, and this
    renaming is a part of an effort to make it easier to us to update these
    scripts, when there's a pip release. It's also essential for improving how we
    handle the `get-pip.py` scripts, when pip drops support for a Python minor
    version.
    
    There are no more renames/URL changes planned, and we don't expect that a need
    would arise to do this again in the near future.
    
    Thanks for understanding!
    
    - Pradyun, on behalf of the volunteers who maintain pip.
    
    [root@localhost ~]# curl  https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 1863k  100 1863k    0     0   5126      0  0:06:12  0:06:12 --:--:--  3265
    [root@localhost ~]# python get-pip.py
    DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
    Collecting pip<21.0
      Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
         |████████████████████████████████| 1.5 MB 28 kB/s
    Collecting wheel
      Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
    Installing collected packages: pip, wheel
    Successfully installed pip-20.3.4 wheel-0.36.2
    [root@localhost ~]# pip install pynmea2
    DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
    Collecting pynmea2
      Downloading pynmea2-1.17.0.tar.gz (30 kB)
    Building wheels for collected packages: pynmea2
      Building wheel for pynmea2 (setup.py) ... done
      Created wheel for pynmea2: filename=pynmea2-1.17.0-py2-none-any.whl size=27820 sha256=6c05e42d7476888e2a176c99da76a846b3ee88ae9033ff2a74a72b79e582deff
      Stored in directory: /root/.cache/pip/wheels/0c/cc/d8/3a33ac4348239a58f685f128c2e6d93c4ab26f05d9a6fa4219
    Successfully built pynmea2
    Installing collected packages: pynmea2
    Successfully installed pynmea2-1.17.0
    [root@localhost ~]#which pip
    
    /usr/bin/pip
    
    [root@localhost ~]#
    





    参考:《Linux报错:bash: pip: command not found

    #Linux报错:bash: pip: command not found
    $ wget https://bootstrap.pypa.io/get-pip.py
    $ python get-pip.py
    $ pip -V  #查看pip版本
    
    #接下来就可以随便pip安装东西了
    
     
    
     
    
    #首先查下安装路径:
    
    find / -name pip
    
    #然做个软连接
    
    ln -sv /usr/local/python/bin/pip /usr/bin/pip
    
     




    参考:《在centos7.5中解决bash: pip:command not find 问题

     
    在使用python的时候,有时候会需要找到python包的安装位置,来找其他安装的第三方包。下面我们来看看,在不同平台上,怎么找到python的安装路径。

    对于linux平台来说,很多运行的系统软件都是建立在python的基础之上,如果python出错了,那么整个系统可能会有出现重大问题的风险。我们以CentOS 7为例,在CentOS7中,python基础版本是2.7,如下面图中所示。

    image



    我们可以使用whereis python命令查看其安装路径:

    image


    可以看到路径是/usr/bin/python。
    然后我们可以使用rpm -qf /usr/bin/python命令看看其安装包,如下:

    image

    然后使用rpm -ql python-2.7.5命令,通过Python安装包查看其安装路径,如下:

    image

    这里,我发现centos7.5的自带python2.7,且bin目录下并没有安装pip,因此在这里问题不是环境变量的问题,从而不能单纯从增加环境变量的角度去解决。我们应该做得是直接安装pip工具。过程如下,也比较简洁:

    curl -O https://bootstrap.pypa.io/get-pip.py
     python get-pip.py

    通过上面两条命令就可以完成pip的安装。

    image


    这样,我们就完成了pip工具的安装。此时,通过which pip我们可以在bin目录下找到pip的环境路径。

     


    参考: pynmea2安装 

    1. install
    ubuntu:~$ sudo apt-get install pip
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package pip
    ubuntu:~$ 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
    100 1882k  100 1882k    0     0  19541      0  0:01:38  0:01:38 --:--:-- 32642
    ubuntu:~$
    
    
    ubuntu:~$ python get-pip.py
    ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.6. Please use https://bootstrap.pypa.io/2.7/get-pip.py instead.
    ubuntu:~$ curl  https://bootstrap.pypa.io/2.7/get-pip.py -o get-pip.py   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed
    100 1863k  100 1863k    0     0  34655      0  0:00:55  0:00:55 --:--:-- 26360
    
    
    ubuntu:~$ python get-pip.py
    DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
    Defaulting to user installation because normal site-packages is not writeable
    Collecting pip<21.0   Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)      |ΖΖΖΖΖΖΖΖΖΖΖΖΖΖΖΖ| 1.5 MB 309 kB/s
    Collecting setuptools<45   Downloading setuptools-44.1.1-py2.py3-none-any.whl (583 kB)      |ΖΖΖΖΖΖΖΖΖΖΖΖΖΖΖΖ| 583 kB 6.3 MB/s
    Collecting wheel   Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
    Installing collected packages: pip, setuptools, wheel
    Successfully installed pip-20.3.4 setuptools-44.1.1 wheel-0.36.2
    ubuntu:~$
    
    
    ubuntu:~$ pip install pynmea2
    DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
    Defaulting to user installation because normal site-packages is not writeable
    Collecting pynmea2   Downloading pynmea2-1.16.0.tar.gz (30 kB)
    Building wheels for collected packages: pynmea2   Building wheel for pynmea2 (setup.py) ... done   Created wheel for pynmea2: filename=pynmea2-1.16.0-py2-none-any.whl size=27827 sha256=2d72ef313aae82f8a161df8206503016f936180689a1cf4b4c1b70bcbee134a8   Stored in directory: /home/jasonfan/.cache/pip/wheels/32/70/a4/e0cb05320aabe53e07dedeb57fb8ead56d48fb3c26cbf6dd04
    Successfully built pynmea2
    Installing collected packages: pynmea2
    Successfully installed pynmea2-1.16.0
    ubuntu:~$
    
    2.test  (1)@ubuntu:~/pynmea2/examples$ python ./read_file.py
    Traceback (most recent call last):   File "./read_file.py", line 4, in <module>     file = open('data.log','r',encoding='utf-8')
    TypeError: 'encoding' is an invalid keyword argument for this function
    
    solve:  >import io
    >file = io.open('data.log','r',encoding='utf-8')   ~   
    为人:谦逊、激情、博学、审问、慎思、明辨、 笃行
    学问:纸上得来终觉浅,绝知此事要躬行
    为事:工欲善其事,必先利其器。
    态度:道阻且长,行则将至;行而不辍,未来可期
    转载请标注出处!
  • 相关阅读:
    lua 计算字符串字符个数“中文字算一个字符”
    C API
    词汇
    LUA 创建文件和文件夹
    lua lfs库
    Unity3d gameObject
    Unity3d Time
    Unity3d Vector3
    Unity3d transform
    从Oracle数据库中的本地命名文件tnsnames.ora来看服务别名、服务名和实例名的区别。
  • 原文地址:https://www.cnblogs.com/ios9/p/14624744.html
Copyright © 2011-2022 走看看