Description of problem: After installing python-jinja2, python cannot find jinja2 Version-Release number of selected component (if applicable): 2.6.2.el6 How reproducible: Install python-jinja2 and try to use jinja2 Steps to Reproduce: 1. yum install python-jinja2 2. python -c 'import jinja2' Actual results: ImportError: No module named jinja2 Expected results: Exits successfully Additional info: The difference between the fc17 RPM and the el6 RPM is that fc17 installs jinja2 into /usr/lib/python2.7/site-packages/jinja2, whereas el6 installs it into /usr/lib/python2.6/site-packages/Jinja2-2.6-py2.6.egg/jinja2 - the extra Jinja2-2.6-py2.6.egg is what stops python finding it. The fix would be to install jinja2 into the site-packages directory directly, or add a jinja2.pth file that adds the Jinja2-2.6-py2.6.egg to the sys.path (the former is the fc17 approach)
Actually, there are two different packages: python-jinja2 is from RHEL6, (rather old) version 2.2.1, and python-jinja2-26 is from EPEL6, (newer) version 2.6. Obviously, the EPEL package cannot install into site-packages/jinja2, but only installs into site-packages/Jinja2-2.6-py2.6.egg. In order to import the module, you have to modify sys.path as such: >>> import sys >>> sys.path.insert(0, '/usr/lib/python2.6/site-packages/Jinja2-2.6-py2.6.egg') >>> import jinja2 For more details, see https://fedoraproject.org/wiki/Packaging:Python_Eggs#Multiple_Versions This is also explained in /usr/share/doc/python-jinja2-26-2.6/README.Fedora.
A better, more sustainable/flexible solution is to use the following two lines at the top of every application: ``` ## These two lines are needed to run on EL6 __requires__ = ['SQLAlchemy >= 0.7', 'jinja2 >= 2.4'] import pkg_resources ``` The SQLAlchemy part is of course optional and depends on your application.