为 python 安装 stringtemplate3

发布于 2024-12-24 22:43:01 字数 780 浏览 4 评论 0原文

我尝试运行 Python/cminus 示例。 从http://pypi.python.org/pypi/stringtemplate3/3.1,我使用sudo python setup.py install为python安装了stringtemplate3。

当我运行以这段代码开头的 cminus.py 时。

import sys
import antlr3
import stringtemplate3

我有错误。

Traceback (most recent call last):
  File "cminus.py", line 3, in <module>
    import stringtemplate3
  File "/Library/Python/2.7/site-packages/stringtemplate3/__init__.py", line 14, in <module>
    from stringtemplate3.templates import *
  File "/Library/Python/2.7/site-packages/stringtemplate3/templates.py", line 35, in <module>
    import antlr
ImportError: No module named antlr

看起来 stringtemplate3 使用antlr而不是antlr3。

我该如何解决这个问题?

I tried to run Python/cminus example.
From http://pypi.python.org/pypi/stringtemplate3/3.1, I installed stringtemplate3 for python with sudo python setup.py install.

When I run cminus.py that starts with this code.

import sys
import antlr3
import stringtemplate3

I got errors.

Traceback (most recent call last):
  File "cminus.py", line 3, in <module>
    import stringtemplate3
  File "/Library/Python/2.7/site-packages/stringtemplate3/__init__.py", line 14, in <module>
    from stringtemplate3.templates import *
  File "/Library/Python/2.7/site-packages/stringtemplate3/templates.py", line 35, in <module>
    import antlr
ImportError: No module named antlr

It looks like that stringtemplate3 uses antlr not antlr3.

How can I solve this issue?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁人与我共长歌 2024-12-31 22:43:01

我从此页面得到了答案 - 哪里可以获得 Python ANTLR 包使用 StringTemplate?

  1. 转到 http://www.antlr2.org/download/antlr-2.7.7.ta​​r.gz
  2. 解压到lib/python目录
  3. 运行sudo python setup.py install

我必须从antlr2.7安装antler

I got an answer from this page - Where to get Python ANTLR package to use StringTemplate?

  1. goto http://www.antlr2.org/download/antlr-2.7.7.tar.gz
  2. unzip it to go to lib/python directory
  3. run sudo python setup.py install.

I had to install antler from antlr2.7

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文