英文:
Import "antlr4" could not be resolved
问题
我已经通过brew install antlr
安装了antlr,但在我的VSCode中无法导入它,出现以下错误:Import "antlr4" could not be resolved
。如何解决这个问题?
我已经尝试重新安装antlr,但没有起作用。感谢您的帮助。
英文:
I have already install antlr through
brew install antlr
but i cant import it in my vscode with this error
Import "antlr4" could not be resolved
How can i solve this problem?
I have tried reinstall the antlr but it didnt work.
Thanks for ur help.
答案1
得分: 0
不要使用brew安装ANTLR。brew的可能是旧版本。首先执行brew uninstall antlr
。
请理解可以通过pip(或其他非Python软件包管理器)安装两种不同的东西:
- ANTLR运行时,用于运行由ANTLR工具生成的解析器/词法分析器代码。
- ANTLR工具,负责将您的
.g4
语法文件转换为解析器/词法分析器类(在您的情况下是Python代码)。
pip3 install antlr4-python3-runtime
(显然)仅安装运行时。如果要将语法转换为解析器/词法分析器代码,请执行pip3 install antlr4-tools
。
有关更详细的信息,请参阅官方ANTLR入门指南。
但它没有起作用
如果仍然遇到问题,请尝试提供更详细的信息,而不仅仅是“但它没有起作用”,这样无法帮助他人帮助您。
英文:
Don't use brew to install ANTLR. Whatever comes from brew is most probably old. First do brew uninstall antlr
.
Understand that there are 2 different things you can install through pip (or other non-Python package managers):
- the ANTLR runtime, needed to run parser/lexer code that is generated by the ANTLR tool
- the ANTLR tool, responsible for converting yout
.g4
grammar file into parser/lexer classes (Python code in your case)
pip3 install antlr4-python3-runtime
(obviously) installs only the run-time. If you want to convert a grammar into parser/lexer code, do pip3 install antlr4-tools
instead.
See the official ANTLR getting started guide for more detailed information.
> but it didnt work
If you still have problems, try updating your question with more detailed information than things like "but it didnt work", which does not help others help you.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论