Search code examples
python-2.7pipcentos7setuptoolsyum

CentOS 7: reinstalling python2.7 and yum


I removed by mistake /usr/lib64/libpython2.7.so, and as a consequence, yum does not work. So I'm trying to reinstall python2.7.18 (which is the version that I currently have) from source, but in compilation I get that some modules are missing

Python build finished, but the necessary bits to build these modules were not found:
_bsddb             _curses            _curses_panel   
_ssl               _tkinter           bsddb185        
bz2                dl                 imageop         
readline           sunaudiodev                        
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

But: yum doesn't work, pip2 also doesn't work, setuptools for python setup.py install is not found... And all solutions I'm finding involve some of those, so I'm getting into some circular problem here.
I looked for the *.rpm for python 2.7.18 for CentOS 7, in the hope I could just install it with rpm and solve the issue, but I couldn't find it.

Any idea?


Solution

  • Found a solution, starting from here.

    After manually rm-ing all the /usr/**/*python2.7* files (probably just the libpython2.7.so* and the python2.7 executables would be enough), from http://mirror.centos.org/centos/7/os/x86_64/Packages/, I downloaded

    bzip2-devel-1.0.6-13.el7.x86_64.rpm
    compat-db-4.7.25-28.el7.x86_64.rpm
    dlm-devel-4.0.7-1.el7.x86_64.rpm
    dlm-lib-4.0.7-1.el7.x86_64.rpm
    gdbm-1.10-8.el7.x86_64.rpm
    gdbm-devel-1.10-8.el7.x86_64.rpm
    keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm
    krb5-devel-1.15.1-46.el7.x86_64.rpm
    libcom_err-devel-1.42.9-17.el7.x86_64.rpm
    libdb-devel-5.3.21-25.el7.x86_64.rpm
    libdb-tcl-5.3.21-25.el7.x86_64.rpm
    libdb-tcl-devel-5.3.21-25.el7.x86_64.rpm
    libselinux-devel-2.5-15.el7.x86_64.rpm
    libsepol-devel-2.5-10.el7.x86_64.rpm
    libverto-devel-0.2.5-4.el7.x86_64.rpm
    ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm
    openssl-devel-1.0.2k-19.el7.x86_64.rpm
    pkgconfig-0.27.1-4.el7.x86_64.rpm
    python-2.7.5-88.el7.x86_64.rpm
    python-devel-2.7.5-88.el7.x86_64.rpm
    python-libs-2.7.5-88.el7.x86_64.rpm
    python-pycurl-7.19.0-19.el7.x86_64.rpm
    sqlite-3.7.17-8.el7_7.1.x86_64.rpm
    sqlite-devel-3.7.17-8.el7_7.1.x86_64.rpm
    sqlite-tcl-3.7.17-8.el7_7.1.x86_64.rpm
    python-setuptools-0.9.8-7.el7.noarch.rpm
    python-six-1.9.0-2.el7.noarch.rpm
    python-tools-2.7.5-88.el7.x86_64.rpm
    python-urlgrabber-3.10-10.el7.noarch.rpm
    readline-6.2-11.el7.x86_64.rpm
    readline-devel-6.2-11.el7.x86_64.rpm
    popt-devel-1.13-16.el7.x86_64.rpm
    rpm-4.11.3-43.el7.x86_64.rpm
    rpm-apidocs-4.11.3-43.el7.noarch.rpm
    rpm-build-4.11.3-43.el7.x86_64.rpm
    rpm-build-libs-4.11.3-43.el7.x86_64.rpm
    rpm-devel-4.11.3-43.el7.x86_64.rpm
    rpmdevtools-8.3-5.el7.noarch.rpm
    rpm-libs-4.11.3-43.el7.x86_64.rpm
    rpm-python-4.11.3-43.el7.x86_64.rpm
    sqlite-3.7.17-8.el7_7.1.x86_64.rpm
    sqlite-devel-3.7.17-8.el7_7.1.x86_64.rpm
    tcl-devel-8.5.13-8.el7.x86_64.rpm
    tix-8.4.3-12.el7.x86_64.rpm
    tix-devel-8.4.3-12.el7.x86_64.rpm
    tk-devel-8.5.13-6.el7.x86_64.rpm
    tkinter-2.7.5-88.el7.x86_64.rpm
    yum-3.4.3-167.el7.centos.noarch.rpm
    yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
    zlib-devel-1.2.7-18.el7.x86_64.rpm
    

    and installed them with sudo rpm -Uvh --replacepkgs --force *.rpm.

    Yum works fine now.