Reputation: 149
I installed python26 on my CentOS 5.3 machine using the following command. Now I have both python 2.4.3 and python 2.6 running on that machine.
yum install python26
When I run a python script with the following in the beginning of the script.
#!/usr/bin/python26
I will get the following error:
Traceback (most recent call last):
File "./centos-errata.py", line 70, in <module>
import rpm
ImportError: No module named rpm
But if I specify the following instead, it will not complain.
#!/usr/bin/python
How can I fix this error? Thanks.
Upvotes: 0
Views: 8955
Reputation: 4872
Have you checked that /usr/bin/python26 indeed exists.
do:
which python
Usually, symlink 'pyton' gets created that points to your most current executable.
Add in your code:
import sys
print sys.version
Then check if you have rpm-python installed.
Finally, it is possible that version or rpm does not match the version of Python you installed.
Be careful with CentOS and version of Python you install - later Python than 2.4 can break yum.
I think for your version, yum is built with Python 2.4.
Here are decent instructions on how to safely upgrade:
http://joshuakehn.com/2011/2/4/Upgrading-Python-on-CentOS.html
Upvotes: 1