2

I am trying to use python drive for age. For this, I directly imported from the age file in the driver code using from age import *. But when I ran the code, I encountered the following error:

File "/home/abhishek/.local/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py", line 50, in checkVersion raise Exception("Could not deserialize ATN with version " + str(version) + " (expected " + str(SERIALIZED_VERSION) + ").") Exception: Could not deserialize ATN with version ☐ (expected 4).

The is there as it is in error.

I tried using the debugger and the error is coming from the file AgtypeLexer.py on the line:

atn = ATNDeserializer().deserialize(serializedATN())

What can be the possible reason for this, and how can this be fixed?

Edit:antlr4-python3-runtime version 4.11.1 is installed properly on the system.

abhishek2046
  • 312
  • 1
  • 11

7 Answers7

3

This error is mainly caused due to the version of antlr4 installed. The code below should solve this:

# When using the apache-age-python package
pip install antlr4-python3-runtime==4.9.2  

    # When importing age from the cloned repository 
pip install antlr4-python3-runtime==4.11.1

Check this thread or this as they already provided solutions for this error.

Tito
  • 289
  • 8
2

Ensure that you have the correct version of the ANTLR runtime installed because the error seems to be related to version mismatch in the ANTLR library used by the age package. You can download the the ANTLR by specifying the version explicitly to avoid conflicts.

pip install antlr4-python3-runtime==4.11.1

If you're using the apache-age-python package, use version 4.11.1. If you're importing directly from the cloned repository, consider using version 4.9.2.

0

The python driver uses antlr runtime version 4.11.1. So you need to install this specific version to run the python driver.

In your terminal run:

pip install antlr4-python3-runtime==4.11.1
Safi50
  • 379
  • 1
  • 7
  • Sorry for not including it in the question. But antlr4-python3-runtime==4.11.1 is already installed but I am still getting the error. – abhishek2046 May 22 '23 at 19:07
0

The error usually occurs when the version of the serialized AN is somwhat different from the version used by the ATN deserializer.

Try this command to update antlr4-python3-runtime version:

pip install --upgrade antlr4-python3-runtime

Also try clearing cache as well.

0

Verify if you have dependency conflicts between different versions of ANTLR or other dependencies in your project, causing the deserialization error. This can happen if there are multiple packages installed that rely on different versions of ANTLR.

Ensure that the ANTLR version you are using is compatible with the serialized ATN version. Check the packages installed in your python enviroment:

pip list
Marcos Silva
  • 115
  • 5
0

Seems like you are using incorrect version of ANTLR runtime. Download the ANTLR with the correct version to avoid conflicts.

pip install antlr4-python3-runtime==4.11.1

Run this command to install ANTLR 4.11.1

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Aadil Bashir
  • 111
  • 5
-1

Is this problem solved? I'm also having a similar issue.

Configuring submodule 'qtinterfaceframework'
CMake Error at qtinterfaceframework/src/interfaceframework/Qt6InterfaceFrameworkMacros.cmake:376 (message):
  Error while running the ifcodegen:


  /home/jinhengzhuang/Qt/6.2.5/Src/host_build/qtinterfaceframework/src/tools/ifcodegen/qtif_qface_virtualenv/bin/python
  /home/jinhengzhuang/Qt/6.2.5/Src/qtinterfaceframework/src/tools/ifcodegen/generate.py
  -T
  /home/jinhengzhuang/Qt/6.2.5/Src/qtinterfaceframework/src/tools/ifcodegen/templates
  --template=frontend --force --module=QtIfVehicleFunctions
  /home/jinhengzhuang/Qt/6.2.5/Src/qtinterfaceframework/src/ifvehiclefunctions/ifvehiclefunctions.qface
  /home/jinhengzhuang/Qt/6.2.5/Src/host_build/qtinterfaceframework/src/ifvehiclefunctions


  Traceback (most recent call last):

    File "/home/jinhengzhuang/Qt/6.2.5/Src/qtinterfaceframework/src/tools/ifcodegen/generate.py", line 40, in <module>
      from qface.generator import FileSystem, Generator
    File "/home/jinhengzhuang/Qt/6.2.5/Src/host_build/qtinterfaceframework/src/tools/ifcodegen/qtif_qface_virtualenv/lib/python3.8/site-packages/qface/generator.py", line 18, in <module>
      from .idl.parser.TLexer import TLexer
    File "/home/jinhengzhuang/Qt/6.2.5/Src/host_build/qtinterfaceframework/src/tools/ifcodegen/qtif_qface_virtualenv/lib/python3.8/site-packages/qface/idl/parser/TLexer.py", line 156, in <module>
      class TLexer(Lexer):
    File "/home/jinhengzhuang/Qt/6.2.5/Src/host_build/qtinterfaceframework/src/tools/ifcodegen/qtif_qface_virtualenv/lib/python3.8/site-packages/qface/idl/parser/TLexer.py", line 158, in TLexer
      atn = ATNDeserializer().deserialize(serializedATN())
    File "/home/jinhengzhuang/Qt/6.2.5/Src/host_build/qtinterfaceframework/src/tools/ifcodegen/qtif_qface_virtualenv/lib/python3.8/site-packages/antlr4/atn/ATNDeserializer.py", line 28, in deserialize
      self.checkVersion()
    File "/home/jinhengzhuang/Qt/6.2.5/Src/host_build/qtinterfaceframework/src/tools/ifcodegen/qtif_qface_virtualenv/lib/python3.8/site-packages/antlr4/atn/ATNDeserializer.py", line 50, in checkVersion
      raise Exception("Could not deserialize ATN with version " + str(version) + " (expected " + str(SERIALIZED_VERSION) + ").")

  Exception: Could not deserialize ATN with version  (expected 4).

Call Stack (most recent call first):
  qtinterfaceframework/src/interfaceframework/Qt6InterfaceFrameworkMacros.cmake:390 (qt6_ifcodegen_generate)
  qtinterfaceframework/src/ifvehiclefunctions/CMakeLists.txt:8 (qt_ifcodegen_generate)