antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.22k stars 3.29k forks source link

Could not deserialize ATN with version (expected 4). #3997

Open moxi828 opened 1 year ago

moxi828 commented 1 year ago

OS:ubuntu 22.04 python:3.10.6 java:1.8 ATN:4.8

python runtime error: raise Exception("Could not deserialize ATN with version " + str(version) + " (expected " + str(SERIALIZED_VERSION) + ").") Exception: Could not deserialize ATN with version (expected 4).

How to solve this problem? thank you

ericvergnaud commented 1 year ago

Hi,Have you tried regenerating your parser?Envoyé de mon iPhoneLe 3 déc. 2022 à 04:15, moxi828 @.***> a écrit : OS:ubuntu 22.04 python:3.10.6 java:1.8 ATN:4.8 python runtime error: raise Exception("Could not deserialize ATN with version " + str(version) + " (expected " + str(SERIALIZED_VERSION) + ").") Exception: Could not deserialize ATN with version (expected 4). How to solve this problem? thank you

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

moxi828 commented 1 year ago

Hi,Have you tried regenerating your parser?Envoyé de mon iPhoneLe 3 déc. 2022 à 04:15, moxi828 @.> a écrit : OS:ubuntu 22.04 python:3.10.6 java:1.8 ATN:4.8 python runtime error: raise Exception("Could not deserialize ATN with version " + str(version) + " (expected " + str(SERIALIZED_VERSION) + ").") Exception: Could not deserialize ATN with version (expected 4). How to solve this problem? thank you —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.>

Sorry, I'm a novice, and I don't know much about this. I'm preparing to learn related knowledge. The above error occurred when I was preparing to run a tool named PiRL. So what should I do to regenerate the parser? Thank you very much for your patience.

ericvergnaud commented 1 year ago

I know nothing about PiRL, so can't really help. Please read the online docs to find out how to regenerate your parser.

moxi828 commented 1 year ago

I know nothing about PiRL, so can't really help. Please read the online docs to find out how to regenerate your parser.

thank you very much

zhangwenmeng111 commented 1 year ago

I know nothing about PiRL, so can't really help. Please read the online docs to find out how to regenerate your parser.

Which file explains how to regenerate my parser?please? I have the same problem when using antlr4, which can not be solved so far. Thank you for your answer.

zhangwenmeng111 commented 1 year ago

I know nothing about PiRL, so can't really help. Please read the online docs to find out how to regenerate your parser.

How should I regenerate my parser? Which online docs shoud l read? Thank you very much!

jcmuel commented 1 year ago

Hi,

I had the same issue with exactly the same error message when I tried to run the 04-Calc example from py3antlr4book.

The GIT repo of py3antlr4book shipped an old version of ANTLR (antlr-4.7.2-complete.jar), which is incompatible with the latest antlr4-python3-runtime that I installed via PyPI (4.11.1).

In my case, I upgraded the version of ANTLR for generating the parser and created a PR to fix the issue in the book: https://github.com/jszheng/py3antlr4book/pull/15. Using the antlr4 executable that ships with antlr4-python3-runtime instead of the JAR from py3antlr4book also solves the problem.

In your case, you probably either have to regenerate the parser of the PiRL tool using the latest ANTLR or downgrade to an older version of the Python 3 package antlr4-python3-runtime if you don't want to make changes in PiRL.

eugenos-programos commented 1 year ago

Try to reinstall antlr4 runtime with appropriate version: pip uninstall antlr4-python3-runtime pip install antlr4-python3-runtime==<ANTLR version> To check your ANTLR version run antlr4 command.

iliyami commented 1 year ago

I downgraded my antlr4-python3-runtime to 4.9.3 and the error fixed.

himito commented 1 year ago

Try to reinstall antlr4 runtime with appropriate version: pip uninstall antlr4-python3-runtime pip install antlr4-python3-runtime==<ANTLR version> To check your ANTLR version run antlr4 command.

I installed with pip install antlr4-python3-runtime==$(antlr4 | grep Version | awk '{print $5;}')

xnerhu commented 10 months ago

python

AI-General commented 8 months ago

Thank you @iliyami

It works