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

LaTeX parser has antlr dependency #131

Open
sidhantnagpal opened this issue Oct 18, 2018 · 8 comments
Open

LaTeX parser has antlr dependency #131

sidhantnagpal opened this issue Oct 18, 2018 · 8 comments

Comments

@sidhantnagpal
Copy link
Member

As LaTeX parser requires antlr-python-runtime, the following code block from the docstring throws an error:

    >>> from sympy.parsing.latex import parse_latex  # doctest: +SKIP
    >>> expr = parse_latex(r"\frac {1 + \sqrt {\a}} {\b}")  # doctest: +SKIP
    >>> expr  # doctest: +SKIP
    (sqrt(a) + 1)/b
    >>> expr.evalf(4, subs=dict(a=5, b=2))  # doctest: +SKIP
    1.618

with the following traceback:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/base/data/home/apps/s~sympy-live-hrd/56.412575950366508090/sympy/sympy/parsing/latex/__init__.py", line 31, in parse_latex
    return _latex.parse_latex(s)
  File "/base/data/home/apps/s~sympy-live-hrd/56.412575950366508090/sympy/sympy/parsing/latex/_parse_latex_antlr.py", line 66, in parse_latex
    raise ImportError("LaTeX parsing requires the antlr4 python package,"
ImportError: LaTeX parsing requires the antlr4 python package, provided by pip (antlr4-python2-runtime or antlr4-python3-runtime) or conda (antlr-python-runtime)
@asmeurer
Copy link
Member

Not likely we can do anything about this, at least with the current Live architecture.

@punish4424
Copy link

I found a solution for this.
Doing pip install antlr4-python3-runtime was not working for me, I was getting the same error.

Follow these steps :-

  1. Install antlr4 from https://pypi.python.org/pypi/antlr4-python3-runtime (for python 3) or https://pypi.python.org/pypi/antlr4-python2-runtime ( for python 2).

  2. Extract the zip folder and inside the src folder you will find a folder named "antlr4". Copy that folder and paste that in your virtual-environment --> lib -- > python(2 or 3) --> site-packages.

  3. Run your script again and it'll work fine.

@SnoozingSimian
Copy link

I found a solution for this.
Doing pip install antlr4-python3-runtime was not working for me, I was getting the same error.

Follow these steps :-

1. Install antlr4 from https://pypi.python.org/pypi/antlr4-python3-runtime (for python 3) or https://pypi.python.org/pypi/antlr4-python2-runtime ( for python 2).

2. Extract the zip folder and inside the src folder you will find a folder named "antlr4". Copy that folder and paste that in your virtual-environment --> lib -- > python(2 or 3) --> site-packages.

3. Run your script again and it'll work fine.

Can you please guide me a little on how to get this set up in a local machine. I don't quite understand which zip folder you are referring to in the second point.

Also, is there any way to do this using a conda installer.

@csdrli
Copy link

csdrli commented Dec 28, 2022

Install an earlier version

pip install antlr4-python3-runtime==4.x.x

@fcrozatier
Copy link

As of 02/2023 you need antlr 4.10 to run parse_latex.
See my answer here

@Mhieu14
Copy link

Mhieu14 commented Sep 21, 2023

This is work for me:
pip install antlr4-python3-runtime==4.11

@Yahuicai
Copy link

Yahuicai commented Aug 1, 2024

This is work for me: pip install antlr4-python3-runtime==4.11

yes!

@asmeurer
Copy link
Member

asmeurer commented Aug 1, 2024

The source for live is now at https://github.com/sympy/live. I don't know where the dependencies are listed but it should be possible to just add this.

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

8 participants