解决Linux服务器无pip命令

梦想不抛弃苦心追求的人,只要不停止追求,你们会沐浴在梦想的光辉之中。再美好的梦想与目标,再完美的计划和方案,如果不能尽快在行动中落实,最终只能是纸上谈兵,空想一番。只要瞄准了大方向,坚持不懈地做下去,才能够扫除挡在梦想前面的障碍,实现美好的人生蓝图。解决Linux服务器无pip命令,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com,来源:原文

解决Linux服务器无pip命令

查看python版本

# 查看python版本
[root@aaa ~]# python --version
Python 2.7.5

下载pip文件

根据python版本下载pip文件,如果文件错误在安装时会有提示

  • 先贴出版本不对的报错
#错误时的情况此处贴出
#[root@aaa ~]# python get-pip.py
#ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.7. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.
  • 根据版本下载pip文件
[root@aaa ~]# wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
--2023-02-14 13:57:16--  https://bootstrap.pypa.io/pip/2.7/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.108.175, 2a04:4e42:8c::175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.108.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1908226 (1.8M) [text/x-python]
Saving to: ‘get-pip.py’

100%[==============================================================================================================================================>] 1,908,226   36.9KB/s   in 58s

2023-02-14 13:58:14 (32.3 KB/s) - ‘get-pip.py’ saved [1908226/1908226]

安装pip

# 安装pip
[root@aaa ~]# 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 21 kB/s
Collecting setuptools<45
  Downloading setuptools-44.1.1-py2.py3-none-any.whl (583 kB)
     |████████████████████████████████| 583 kB 22 kB/s
Collecting wheel
  Downloading wheel-0.37.1-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.37.1

使用pip命令

查看已安装的三方库

[root@aaa ~]# pip list
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.
Package             Version
------------------- -------
configobj           4.7.2
decorator           3.4.0
futures             3.1.1
iniparse            0.4
perf                0.1
pip                 20.3.4
pycurl              7.19.0
pygobject           3.22.0
pygpgme             0.3
pyliblzma           0.5.3
python-linux-procfs 0.4.9
pyudev              0.15
pyxattr             0.5.1
schedutils          0.4
setuptools          44.1.1
six                 1.9.0
slip                0.4.0
slip.dbus           0.4.0
urlgrabber          3.10
wheel               0.37.1
yum-metadata-parser 1.1.4

安装三方库

  • psutil是一个跨平台库(http://pythonhosted.org/psutil/)能够轻松实现获取系统运行的进程和系统利用率(包括CPU、内存、磁盘、网络等)信息。它主要用来做系统监控,性能分析,进程管理。它实现了同等命令行工具提供的功能,如ps、top、lsof、netstat、ifconfig、who、df、kill、free、nice、ionice、iostat、iotop、uptime、pidof、tty、taskset、pmap等。目前支持32位和64位的Linux、Windows、OS X、FreeBSD和Sun Solaris等操作系统.
[root@aaa ~]# pip install psutil
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 psutil
  Downloading psutil-5.9.4-cp27-cp27mu-manylinux2010_x86_64.whl (298 kB)
     |████████████████████████████████| 298 kB 37 kB/s
Installing collected packages: psutil
Successfully installed psutil-5.9.4

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/153999.html

(0)
飞熊的头像飞熊bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!