“Import ‘antlr4’ could not be resolved.”

huangapple go评论92阅读模式
英文:

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软件包管理器)安装两种不同的东西:

  1. ANTLR运行时,用于运行由ANTLR工具生成的解析器/词法分析器代码。
  2. 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):

  1. the ANTLR runtime, needed to run parser/lexer code that is generated by the ANTLR tool
  2. 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.

huangapple
  • 本文由 发表于 2023年6月13日 11:42:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76461567.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定