问题描述
我想做一些代码生成,StringTemplate 看起来是一个非常适合这项工作的工具.我从 PyPi 轻松安装了 stringtemplate3,但是当我尝试导入它时,我得到:
I'd like to do some code generation, and StringTemplate looks like a pretty good tool for the job. I easy_installed stringtemplate3 from PyPi, but when I try to import it I get:
ImportError: No module named antlr
我对此感到困惑,因为我认为 ANTLR 依赖于 StringTemplate(正如网站所说),而不是相反.无论如何,我找不到正确的包来解决这个问题.安装 antlr_python_runtime 没有帮助.
I am confused by this because I thought that ANTLR depended on StringTemplate (as the website says), not the other way around. In any case, I cannot find the correct package to fix this. Installing antlr_python_runtime did not help.
有什么提示吗?
推荐答案
您需要安装 python-antlr
包才能使用 stringtemplate3
.在 Ubuntu 上安装示例:
You need to have the python-antlr
package installed to use stringtemplate3
. Example of installing on Ubuntu:
% sudo aptitude install python-antlr
% virtualenv ~/virt
% . ~/virt/bin/activate
(virt)~% easy_install stringtemplate3
(virt)~% python -c 'import stringtemplate3'
FWIW 这个包在 Macports 上被命名为 py26-antlr3
(不确定你使用的是哪个平台/包管理器).
FWIW this package is named py26-antlr3
on Macports (not sure which platform / package manager you're using).
这篇关于从哪里获取 Python ANTLR 包以使用 StringTemplate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!