python-2.7 - 错误 : Problem: conflicting requests - nothing provides/usr/bin/python needed by python-chardet in CentOS 8

标签 python-2.7 path rpm centos8

我正在使用 CentOS 8 并想下载 Python2 的库。

CentOS 8 默认安装了 Python3 及其库。

我想为 Python2 下载 python-chardet 库。所以我尝试按如下方式安装它 -

$ sudo yum install python-chardet

我遇到了这个错误-

No match for argument: python-chardet
Error: Unable to find a match: python-chardet

我搜索了解决方案,根据此文档,您必须下载其 RPM 二进制文件并进行安装。 https://centos.pkgs.org/7/centos-x86_64/python-chardet-2.2.1-3.el7.noarch.rpm.html

下载二进制文件-

$ wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm

使用这个 rpm 库,我尝试如下安装 python-chardet -

$ sudo yum install ./python-chardet-2.2.1-3.el7.noarch.rpm

这里我遇到了这样的错误-

Error:
 Problem:  conflicting requests
  - nothing provides /usr/bin/python needed by python-chardet-2.2.1-3.el7.noarch

Python版本是

$ python -V

$ Python 2.7.16

/usr/bin/python 返回了这个

Python 2.7.16 (default, Nov 17 2019, 00:07:27)

GCC 8.3.1 (RedHat) on linux2

非常感谢有关此的任何帮助。

最佳答案

CentOS/RHEL 8 默认没有安装任何面向用户的 Python。

它为 dnf 等系统应用程序安装了 Python 3,但要以用户身份使用它,您需要 sudo dnf install python3

同样,Python 2 及其所有内容都可以通过使用适当的包名称后缀来安装。要安装 Python 2 和您需要的模块:

sudo dnf install python2 python2-chardet

建议/默认是未版本化的 python 命令应该不起作用,您应该通过键入 python2 而不是 python 在 shell 上调用所需的 Python 版本

如果出于任何原因您需要未版本化的 python 命令来调用 Python 2,请使用替代系统:

sudo alternatives --set python /usr/bin/python2

关于python-2.7 - 错误 : Problem: conflicting requests - nothing provides/usr/bin/python needed by python-chardet in CentOS 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60603445/

相关文章:

MATLAB 使用!使用自定义路径运行程序

linux - 如何强制RPM在单个目录中安装文件,可能吗?

rpmbuild 跳过 "checking for unpackaged file(s)/usr/lib/rpm/check-files"

python - scrapy while 循环中出现 ReactorNotRestartable 错误

java - tomcat服务器应用路径问题

python - 使用计时器逐行读取

path - JAVA_HOME还是PATH还是两者?

linux - RPM SPEC Systemd 启用并启动

python - 如何随机化 "noise"库的种子

python - .bashrc 中设置的 Fabric 环境变量不可用