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

shreyas.k picture shreyas.k · Mar 9, 2020 · Viewed 7.9k times · Source

I am using CentOS 8 and want to download a library for Python2.

CentOS 8 has Python3 and its libraries installed by default.

I want to download python-chardet library for Python2. So I tried to install it as below -

$ sudo yum install python-chardet

I got this error -

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

I searched for solution and as per this document you have to download its RPM binary and install it. https://centos.pkgs.org/7/centos-x86_64/python-chardet-2.2.1-3.el7.noarch.rpm.html

Downloading the binary file -

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

Using this rpm library I tried to install python-chardet as below -

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

Here I got an error like this -

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

Python version is

$ python -V

$ Python 2.7.16

/usr/bin/python returned this

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

GCC 8.3.1 (RedHat) on linux2

Any help regarding this is much appreciated.

Answer

Danila Vershinin picture Danila Vershinin · Mar 9, 2020

CentOS/RHEL 8 doesn't have any user-facing Python installed by default.

It has Python 3 installed for system apps like dnf, but to use it as a user, you need sudo dnf install python3.

Similarly, Python 2 and everything for it can be installed by using the appropriate package name suffix. To install Python 2 and the module you need:

sudo dnf install python2 python2-chardet

The recommendation/default is that the unversioned python command should not work and you should invoke the desired Python version on the shell by typing python2 instead of python.

If, for whatever reason you need unversioned python command to invoke Python 2, use the alternatives system:

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