Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new version antlr4-python3-runtime 4.13.1 import latex2sympy2 error #4638

Open
xiezhipeng-git opened this issue Jun 8, 2024 · 0 comments

Comments

@xiezhipeng-git
Copy link

xiezhipeng-git commented Jun 8, 2024

pip install sympy
pip install latex2sympy2
pip install antlr4-python3-runtime
pip install -U antlr4-python3-runtime
version = 4.13.1
in windows wsl2

from latex2sympy2 import latex2sympy
then

Exception                                 Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/latex2sympy2.py:8
      [7](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/latex2sympy2.py:7) try:
----> [8](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/latex2sympy2.py:8)     from gen.PSParser import PSParser
      [9](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/latex2sympy2.py:9)     from gen.PSLexer import PSLexer

File ~/.local/lib/python3.10/site-packages/gen/PSParser.py:556
    [553](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/gen/PSParser.py:553)         return buf.getvalue()
--> [556](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/gen/PSParser.py:556) class PSParser (Parser):
    [558](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/gen/PSParser.py:558)     grammarFileName = "PS.g4"

File ~/.local/lib/python3.10/site-packages/gen/PSParser.py:560, in PSParser()
    [558](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/gen/PSParser.py:558) grammarFileName = "PS.g4"
--> [560](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/gen/PSParser.py:560) atn = ATNDeserializer().deserialize(serializedATN())
    [562](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/gen/PSParser.py:562) decisionsToDFA = [DFA(ds, i) for i, ds in enumerate(atn.decisionToState)]

File ~/.local/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py:28, in ATNDeserializer.deserialize(self, data)
     [27](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py:27) self.pos = 0
---> [28](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py:28) self.checkVersion()
     [29](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py:29) atn = self.readATN()

File ~/.local/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py:50, in ATNDeserializer.checkVersion(self)
     [49](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py:49) if version != SERIALIZED_VERSION:
---> [50](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/antlr4/atn/ATNDeserializer.py:50)     raise Exception("Could not deserialize ATN with version " + str(version) + " (expected " + str(SERIALIZED_VERSION) + ").")

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

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
Cell In[1], [line 2](vscode-notebook-cell:?execution_count=1&line=2)
      [1](vscode-notebook-cell:?execution_count=1&line=1) import re
----> [2](vscode-notebook-cell:?execution_count=1&line=2) from latex2sympy2 import latex2sympy
      [3](vscode-notebook-cell:?execution_count=1&line=3) # latex2sympy2
      [5](vscode-notebook-cell:?execution_count=1&line=5) def find_all_boxed_content(text):
      [6](vscode-notebook-cell:?execution_count=1&line=6)     # 使用递归正则表达式来匹配嵌套的括号

File ~/.local/lib/python3.10/site-packages/latex2sympy2.py:12
     [10](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/latex2sympy2.py:10)     from gen.PSListener import PSListener
     [11](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/latex2sympy2.py:11) except Exception:
---> [12](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/latex2sympy2.py:12)     from .gen.PSParser import PSParser
     [13](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/latex2sympy2.py:13)     from .gen.PSLexer import PSLexer
     [14](https://vscode-remote+wsl-002bubuntu-002d22-002e04.vscode-resource.vscode-cdn.net/home/xzpwsl2/my/work/kaggle_code/deepseek-math/~/.local/lib/python3.10/site-packages/latex2sympy2.py:14)     from .gen.PSListener import PSListener

ImportError: attempted relative import with no known parent package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant