I have default python 2.7 and i try to install python3.3 and install pip3 and Django.now when i try to install others using yum i got this error.for a example yum update
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.5 (default, Nov 12 2013, 16:18:42) [GCC 4.8.2 20131017 (Red Hat 4.8.2-1)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
How can i fix this error?
There is probably many python versions on your system and only one of them has the yum library installed. For some reason the python binary called when you run yum
on the command line is not the one who has the yum library installed.
Find the list of python 2 binaries available on your system. Run as root:
find / -type f -executable -name 'python2*'
The output will probably look like that:
/usr/bin/python2.6
/usr/bin/python2.7
...
etc...
For each one of these, run
/usr/bin/python2.x
You'll get a python prompt. Run:
>>> import yum
Do this for every python binary until you find one that doesn't raise an ImportError at this step.
Then find out what is the path that yum is using to run python. This is the first line in the yum script. Run
cat `which yum` | head -1
You'll probably get:
#!/usr/bin/python
Now, run as root:
ln -s /usr/bin/python2.x /usr/bin/python
(replace python2.x with the good python version you found earlier).
I have the same problem.
Yum
has been written in Python lang.
So when you upgrade your default Python to new version it will make problem for yum
.
If you get python --version
it will tell you 3.3.
For solving this problem , change python
command to python2.7
.
First check it:
user@host:~$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 Sep 28 2013 /usr/bin/python -> python3.3
Try it:
mv /usr/bin/python /usr/bin/python-origin
ln -s python2.7 /usr/bin/python
Then check it:
user@host:~$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 Sep 28 2013 /usr/bin/python -> python2.7
If you wish to install python3 in CentOS you should install that via source code.
download main source code via python.org website.
extract archive file.
./configure
make
make install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With