Pyramid_jinja2: Importerror: Cannot Import Name Environment
Solution 1:
@Michael Merickel is right. You have a conflict between your jinja2
module and real one. This mistake grows from python2 import politics. But you can add to first line of your script magic sentence from __future__ import absolute_import
. It changes relative import to absolute.
More information: PEP 0328 -- Imports: Multi-Line and Absolute/Relative
But my solution doesn't help you if you want to execute your script from /home/bk/pg/pyramid/quick_tutorial/
. Because in this situation where will be two possible way to resolve import jinja2
.
Solution 2:
It's hard to say but my first guess is that it looks like you named your project jinja2
and that's going to conflict with the jinja2
package in some weird ways depending on what module is doing the imports etc.
Solution 3:
In my case where I was using pip install -r requirements.txt
to install all packages for a Django project on an Ubuntu machine, I ran into this error and many other installation errors.
To solve this one, I uninstalled and reinstalled Jinja2, and it worked.
Also, be careful to use pip3/pip3.x based on which Python version you are using instead of just pip because the default python interpreter in Ubuntu is Python2.7
Post a Comment for "Pyramid_jinja2: Importerror: Cannot Import Name Environment"