I have to installed Python 2.7 in centos as I was facing some issues managing different versions of python. But I have messed up the yum settings and not able to use it.
Steps I took to install Python
cd /usr/src
wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
tar xzf Python-2.7.18.tgz
cd Python-2.7.18
./configure --enable-optimizations
make install
python -V
Output
Python 2.7.18
When I type 'yum' I receive following message.
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.7.18 (default, Dec 7 2020, 22:27:41)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
I have referred to similar questions like this, and I will add the response here.
find / -type f -executable -name 'python2*'
/usr/local/bin/python2.7-config
/usr/local/bin/python2.7
find / -type f -executable -name 'python3*'
/usr/bin/python3.4m
/usr/bin/python3.6m-config
/usr/bin/python3.4
/usr/bin/python3.6
/usr/bin/python3.6m
/usr/bin/python3.6m-x86_64-config
Running /usr/local/bin/python2.7 (this raises a import error)
Python 2.7.18 (default, Dec 7 2020, 22:27:41)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import yum
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named yum
cat which yum
| head -1
#!/usr/bin/python
then as root, I run the following to create a symbolic link
ln -s /usr/local/bin/python2.7 /usr/bin/python
But I am still facing the same issue while running yum command.
Adding more info on yum, rpm -q yum
yum-3.4.3-168.el7.centos.noarch
Verify if yum is installed or not, rpm -V yum-3.4.3-168.el7.centos.noarch.rpm
package yum-3.4.3-168.el7.centos.noarch.rpm is not installed
Then I downloaded this binary package http://mirror.centos.org/altarch/7/os/aarch64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm from here, and installing it with
rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm
but it says that yum is installed
Preparing... ################################# [100%]
package yum-3.4.3-168.el7.centos.noarch is already installed
checking yum file, cat /usr/bin/yum
#!/usr/bin/python
import sys
try:
import yum
except ImportError:
print >> sys.stderr, """\
Update:
output of ls -l /usr/bin/python
lrwxrwxrwx 1 root root 24 Dec 8 09:41 /usr/bin/python -> /usr/local/bin/python2.7