Deleted default python and yum is broken

Issues related to applications and software problems and general support
Post Reply
sanjay_patil
Posts: 1
Joined: 2022/12/19 07:10:05

Deleted default python and yum is broken

Post by sanjay_patil » 2022/12/19 07:28:03

Hello, I'm new to Linux, I wanted to use python3.9 but my system had python3.6 I deleted entire python I didn't know yum is dependent on it, now I installed python3-libs-3.6.8-49.el8.x86_64.rpm from http://mirror.centos.org/centos/8-strea ... /Packages/ but yum is broken it says :

Code: Select all

Traceback (most recent call last):
  File "/usr/bin/yum", line 57, in <module>
    from dnf.cli import main
ModuleNotFoundError: No module named 'dnf'
PYTHONPATH="/usr/local/lib/python3.6/site-packages/:/usr/local/lib/python3.6/:/usr/bin/python3.6/lib/python3.6/lib-dynload"
PYTHONHOME=/usr/bin/python3.6

OS : RHEL 8.7(Ootpa)

I wanted to know am I going in the right way? is the package I downloaded correct?

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Deleted default python and yum is broken

Post by TrevorH » 2022/12/19 13:41:45

The packages that contain the python used by yum etc are called platform-python.

Code: Select all

[root@rocky8 ~]# rpm -qa platform\*
platform-python-setuptools-39.2.0-6.el8.noarch
platform-python-pip-9.0.3-22.el8.rocky.0.noarch
platform-python-3.6.8-48.el8_7.rocky.0.x86_64
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Deleted default python and yum is broken

Post by jlehtone » 2022/12/19 15:21:59

Note that package versions in CentOS Stream 8 can differ.

Furthermore, the the "platform python" is only for the system; not for the user.
For user there are currently four streams:

Code: Select all

# dnf -q module list python\*
AlmaLinux 8 - x86_64 - AppStream - SBL
Name              Stream              Profiles                   Summary                                          
python27          2.7 [d]             common [d]                 Python programming language, version 2.7         
python36          3.6 [d][e]          build, common [d]          Python programming language, version 3.6         
python38          3.8 [d][e]          build, common [d]          Python programming language, version 3.8         
python39          3.9 [d][e]          build, common [d]          Python programming language, version 3.9         

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Note also that streams have unique names, unlike, say 'php':

Code: Select all

# dnf -q module list php\*
AlmaLinux 8 - x86_64 - AppStream - SBL
Name              Stream               Profiles                                Summary                            
php               7.2 [d]              common [d], devel, minimal              PHP scripting language             
php               7.3                  common [d], devel, minimal              PHP scripting language             
php               7.4                  common [d], devel, minimal              PHP scripting language             
php               8.0                  common [d], devel, minimal              PHP scripting language 
This means that while system can have exactly one version of php installed, it can have all four python versions simultaneously installed.

There can be only one "python3" command though, but one can set it to desired version via alternatives:

Code: Select all

# ll /usr/bin/python3
lrwxrwxrwx. 1 root root 25 May 19  2022 /usr/bin/python3 -> /etc/alternatives/python3
# ll /etc/alternatives/python3
lrwxrwxrwx. 1 root root 18 Nov 27 15:31 /etc/alternatives/python3 -> /usr/bin/python3.9
# ll /usr/bin/python3.9
-rwxr-xr-x. 1 root root 7768 Nov 16 17:53 /usr/bin/python3.9
In other words you had no need to remove the "python36" stream; you could simply have added the "python39" stream.

The `yum` is merely a symbolic link to command `dnf`, which is a python3.6 application.
You probably miss some of those packages too.

Code: Select all

# rpm -qa \*dnf\*
dnf-plugin-spacewalk-2.8.5-11.module_el8.3.0+2053+3ddf2832.noarch
dnf-plugins-core-4.0.21-14.1.el8.noarch
libdnf-0.63.0-11.1.el8.alma.x86_64
dnf-4.7.0-11.el8.alma.noarch
python3-dnf-plugin-spacewalk-2.8.5-11.module_el8.3.0+2053+3ddf2832.noarch
python3-dnf-4.7.0-11.el8.alma.noarch
python3-dnf-plugins-core-4.0.21-14.1.el8.noarch
python3-libdnf-0.63.0-11.1.el8.alma.x86_64
kpatch-dnf-0.4-3.el8.noarch
dnf-data-4.7.0-11.el8.alma.noarch

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Deleted default python and yum is broken

Post by TrevorH » 2022/12/19 15:33:46

The `yum` is merely a symbolic link to command `dnf`, which is a python3.6 application.
dnf uses platform-python not any of the module streams. It should be completely self contained and not dependent on any of the modules. Its shebang line is and should be "#!/usr/libexec/platform-python".
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Deleted default python and yum is broken

Post by jlehtone » 2022/12/20 04:56:26

Yes, that is an important detail.

IIRC, the el8 does not install any python for user by default. (Except the platform-python).
Furthermore, while the other streams provide their own binaries, the python36 simply symlinks to platform-python; there is no reason to have two distinct copies.

Post Reply