Python3: 如何导入antlr4

Python3: how to import antlr4

我正在尝试将 antlr4 导入 python3 代码,但出现错误:

$ python3 test.py
Traceback (most recent call last):
  File "test.py", line 3, in <module>
    import antlr4
ImportError: No module named 'antlr4'

我确定antlr4已经存在于我的电脑中:

$ antlr4
ANTLR Parser Generator  Version 4.5.1
 -o ___              specify output directory where all output is generated
 -lib ___            specify location of grammars, tokens files
...

我也尝试了 2 个小测试,test.py 有效:

#!/usr/bin/python3
import os, re, sys
print('test')

但这个版本没有:

#!/usr/bin/python3
import os, re, sys
import antlr4
print('test')

请问如何将此 antlr4 模块与 python 连接? 提前致谢

嗯,在 this page.

上寻求帮助似乎没问题

包裹内容:

https://pypi.python.org/packages/0b/6b/30c5b84d203b62e1412d14622e3bae6273399d79d20f3a24c8145213f610/antlr4-python3-runtime-4.7.tar.gz#md5=190245a0fb4abf43568489a4b6e33aba

与pip3安装的包不同

我已经用我手动下载和提取的包中的内容替换了.../python3.5/antlr4 的内容:

~/Downloads/antlr4-python3-runtime-4.7/src/antlr4

希望对其他人有帮助:)