解决Linux服务器无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
  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一、检查网络连接: 1. 确保网络连接正常,可以尝试访问其他网站或使用其他网络设备检查。 2. 确认自己是否使用了代理服务器,如果使用了代理服务器,需要在pip命令中添加代理参数。 二、检查DNS设置: 1. 确认DNS解析的设置是否正确。可以尝试使用其他DNS服务器来解析域名。 2. 如果使用了自定义的DNS设置,可以尝试恢复到默认的DNS设置。 三、检查防火墙设置: 1. 如果使用了防火墙,确认是否有阻止pip命令的规则。可以试着关闭防火墙或在防火墙中添加相应的规则。 2. 也可以尝试使用命令修改防火墙设置,例如:sudo ufw allow 80。 四、调整pip源: 1. 可以尝试修改pip使用的镜像源,将其替换为其他可用的源。常用的源有阿里云、清华等。 2. 可以使用以下命令来替换源:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 包名。 五、使用代理服务器: 1. 如果没有设置代理服务器,可以考虑使用代理服务器进行连接。 2. 可以使用以下命令来配置代理服务器pip --proxy 用户名:密码@代理服务器:端口 install 包名。 六、更新pip版本: 1. 可以尝试更新pip版本,使用最新的版本可能解决一些问题。 2. 使用以下命令来更新pippip install --upgrade pip。 如果以上步骤都没有解决问题,可以尝试使用其他方式来安装需要的软件包,例如手动下载安装包并使用pip命令本地安装。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值