[Python] How to install DNF packages using Yum when Python packages are in a different location

Discussão em 'Python' iniciado por Stack, Março 24, 2025.

  1. Stack

    Stack Membro Participativo

    We have a RHEL 8.10 server, and the default location for Python packages is under /usr/lib/python3.6/site-packages/. This includes, of course, the DNF packages located at /usr/lib/python3.6/site-packages/dnf.

    We installed a new Python version (3.8), and here are the following packages:

    ls -ltr /usr/lib/python3.8/site-packages/
    total 8
    -rw-r--r-- 1 root root 126 Aug 6 2023 easy_install.py
    drwxr-xr-x 2 root root 82 Mar 24 17:57 __pycache__
    drwxr-xr-x 2 root root 170 Mar 24 17:57 setuptools-41.6.0.dist-info
    drwxr-xr-x 5 root root 94 Mar 24 17:57 pkg_resources
    drwxr-xr-x 6 root root 4096 Mar 24 17:57 setuptools
    drwxr-xr-x 2 root root 130 Mar 24 17:57 pip-19.3.1.dist-info
    drwxr-xr-x 5 root root 95 Mar 24 17:57 pip


    Now, we want to install DNF packages, which should be located under /usr/lib/python3.8/site-packages/.

    The problem is that when we try to install DNF using the following command:

    yum localinstall python3-dnf-4.7.0-20.el8.noarch.rpm


    It is not installed under the path /usr/lib/python3.8/site-packages/.

    What is the correct approach to install the DNF packages under /usr/lib/python3.8/site-packages/?

    I also tried this, but it didn't help

    PYTHONPATH=/usr/lib/python3.8/site-packages

    yum localinstall python3-dnf-4.7.0-20.el8.noarch.rpm
    Last metadata expiration check: 0:30:53 ago on Mon 24 Mar 2025 06:35:20 PM UTC.
    Package python3-dnf-4.7.0-20.el8.noarch is already installed.
    Dependencies resolved.
    Nothing to do.
    Complete!

    Continue reading...

Compartilhe esta Página