import flask给出了ImportError:没有名为jinja2的模块

时间:2018-05-17 18:43:19

标签: python flask jinja2 importerror python-2.6

$ sudo /usr/bin/pip2 install flask==0.12
Requirement already satisfied: flask==0.12 in /usr/lib64/python2.6/site-packages
Requirement already satisfied: click>=2.0 in /usr/lib/python2.6/site-packages (from flask==0.12)
Requirement already satisfied: Jinja2>=2.4 in /usr/lib/python2.6/site-packages/Jinja2-2.6-py2.6.egg (from flask==0.12)
Requirement already satisfied: Werkzeug>=0.7 in /usr/lib/python2.6/site-packages (from flask==0.12)
Requirement already satisfied: itsdangerous>=0.21 in /usr/lib/python2.6/site-packages (from flask==0.12)


$ python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> import flask 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/flask/__init__.py", line 19, in <module>
    from jinja2 import Markup, escape
ImportError: No module named jinja2
>>> 

我在安装期间已满足要求,然后在导入期间出现导入错误。这是为什么 ?

1 个答案:

答案 0 :(得分:1)

如果您还没有/usr/lib/python2.6/site-packages/jinja2,则之前的安装可能会被中断。如果是这种情况,在您的位置我会尝试删除/usr/lib/python2.6/site-packages/Jinja2-2.6-py2.6.egg并再次安装flask == 0.12。

有一个更新版本的Flask可用(和Python一样)。我认为你有理由想要更老的东西。