Skip to content Skip to sidebar Skip to footer

Can't Import Module Antlr Mygrammarlexer And Mygrammarparser

I'm trying to start with ANTLR . When I import module antlr it's working just fine , but if I try to import MyGrammarLexer and MyGrammarParser , it's shows that MyGrammarLexer and

Solution 1:

I found out that content of the package:

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

is different from the package installed by pip3.

I have replaced content of:

~/anaconda3/envs/py3/lib/python3.6/site-packages/antlr4

with content from the package I have downloaded and extracted manually:

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

It seems to be working now - in particular the following error:

ModuleNotFoundError: No module named '__builtin__'

does not occur.

Solution 2:

I ran into this problem recently when getting the same error using the pddlpy python library. I was able to fix it by doing the following:

pip3 install antlr4-python3-runtime==4.9

The version 4.9 at the end is very important.

Solution 3:

After posting your traceback I can see the error is: ModuleNotFoundError: No module named '__builtin__'

That means the package you try to import is using python2 syntax, but you're using python3.

You should use python2 if you need to run this package, but keep in mind that you probably want to search for a different one if this is a new project.

More about why it's not working here

EDIT They released a package with python3 support, but it seems you installed/used something different. You should verify it.

Post a Comment for "Can't Import Module Antlr Mygrammarlexer And Mygrammarparser"