i am going crazy with an import problem. It should be 'simple' because i have a script (test2.py) with this import inside:
from jinja2 import Environment, FileSystemLoader, PackageLoader,select_autoescape
def myfun(arg1)
...
env = Environment(loader=FileSystemLoader('/var/www/html/templates'),autoescape=select_autoescape(['html', 'xml']))
...
Note that this script test2.py is called by test1.py (called by a CGI scripr) like that :
import test2
test2.myfun(arg1)
then i get the error:
from jinja2 import Environment, FileSystemLoader, PackageLoader, select_autoescape
ImportError: cannot import name 'select_autoescape'
the crazy thing is that if i call (directly) another script with these imports: from jinja2 import Environment, FileSystemLoader, PackageLoader,select_autoescape
it goes fine! it does import the select_autoescape thing ...
So my question is why does it not import it when i call it from another function/module?
Try reinstalling jinja2:
sudo pip3 install --upgrade jinja2
It worked for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.