解决Linux服务器无pip命令

解决Linux服务器无pip命令查看python版本下载pip文件安装pip使用pip命令查看已安装的三方库安装三方库

解决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

推荐阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: