导入错误:没有名为 jinja2.filters 的模块 - Python2

发布于 2025-01-20 13:43:10 字数 641 浏览 3 评论 0原文

在基于工作生产的Python程序中,我遇到了基于 Python导入错误基于问题。 我能够使用以下代码行复制问题:

python-test.py

from jinja2.filters import FILTERS, environmentfilter
from jinja2 import Template
import json, re, ast

print "test! There's actual code where the above modules are being used.."

我需要使用Python 2.7.18执行此代码 运行后:python2 python-test.py我会收到以下错误:

追溯(最近的最新电话):
文件“ python-test.py”,第2行,
从jinja2.Filters进口过滤器
Importerror:没有名为Jinja2.filters

的模块

我尝试通过运行:PIP安装Jinja2来安装Jinja2。它已经安装了,但我仍然遇到了这个错误。

有人知道如何解决这个问题吗?

In a work-production based Python program, I encountered a Python import error based issue.
I was able to replicate the issue using below lines of code:

python-test.py

from jinja2.filters import FILTERS, environmentfilter
from jinja2 import Template
import json, re, ast

print "test! There's actual code where the above modules are being used.."

I need to execute this code using Python 2.7.18
After I run: python2 python-test.py I'm getting the following error:

Traceback (most recent call last):
File "python-test.py", line 2, in
from jinja2.filters import FILTERS, environmentfilter
ImportError: No module named jinja2.filters

I tried to install Jinja2 by running: pip install Jinja2. It got installed and yet still I'm getting this error.

Does anyone know how to fix this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文