码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2021-04-08 13:04:02      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:where   none   很多   UNC   instead   lis   ann   ubuntu   span   




在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 ~]#



参考:《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,如下面图中所示。

技术图片



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

技术图片


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

技术图片

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

技术图片

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

 

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

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

技术图片

技术图片


这样,我们就完成了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‘)   ~   

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

标签:where   none   很多   UNC   instead   lis   ann   ubuntu   span   

原文地址:https://www.cnblogs.com/ios9/p/14624744.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!