Where to get Python ANTLR package to use StringTemplate?

随声附和 提交于 2019-12-01 06:43:38

问题


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

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.

Any hints?


回答1:


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 this package is named py26-antlr3 on Macports (not sure which platform / package manager you're using).




回答2:


I was facing the same issue and packaged the antlr python library: you can pip install git+git://github.com/kynan/antlr.git#egg=antlr to install it.



来源:https://stackoverflow.com/questions/5198902/where-to-get-python-antlr-package-to-use-stringtemplate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!