SCANL / swum_project

2 stars 1 forks source link

Antlr import issue #2

Closed VaibhaviRaut closed 4 years ago

VaibhaviRaut commented 4 years ago

I followed the instructions in the swum_phrases -> readme and got the antlr4 installation correctly but am still not able to import the antlr library from lines 11 through 13. I tried referring to the website mentioned as well but I might have missed something?

Can you please guide me with the installations or are there any changes to be made?

antlr_other
BrianPopeck commented 4 years ago

Maybe a typo? Try replacing antlr-python3-runtime with antlr4-python3-runtime.

VaibhaviRaut commented 4 years ago

I was able to install antlr4 using this command 'antlr4-python3-runtime' but I'm not able to resolve this:

from antlr.SwumParser import SwumParser from antlr.SwumParserVisitor import SwumParserVisitor from antlr.SwumLexer import SwumLexer

I tried to run 'antlr-python3-runtime' for the above error but didn't work :P so I tried to check out the website mentioned in the readme which indicated these steps:

Quick Start See Getting Started with ANTLR v4OS X $ cd /usr/local/lib $ sudo curl -O https://www.antlr.org/download/antlr-4.8-complete.jar $ export CLASSPATH=".:/usr/local/lib/antlr-4.8-complete.jar:$CLASSPATH" $ alias antlr4='java -jar /usr/local/lib/antlr-4.8-complete.jar' $ alias grun='java org.antlr.v4.gui.TestRig'

I tried them, nothing really happened.

BrianPopeck commented 4 years ago

The imports from antlr are referring to the directory in the swum_phrases folder, so no need to install anything :)

Your IDE will complain about not being able to resolve the imports -- this is because when you run the swum_phrases script, the script first generates python files in the antlr directory before running SwumPhrases.py. Try the command . ./swum_phrases tests/testcases/simple_success.xml output.xml and see if it works.

Also if you haven't already, I would put the last three commands from the getting started page at the end of your ~/.bashrc file - this will save you from having to re-type them every time you open your terminal.

VaibhaviRaut commented 4 years ago

I tried running the cmd and below is the output, I'm not sure if it worked. Oh and my bad I forgot to mention but I'm using Pycharm IDE.

OUTPUT: _(venv) (base) Vaibhavis-MacBook-Pro:swum_phrases vaibhaviraut$ . ./swum_phrases tests/testcases/simple_success.xml output.xml creating antlr files... bash: antlr4: command not found running phrases layer... Traceback (most recent call last): File "SwumPhrases.py", line 11, in from antlr.SwumParser import SwumParser ModuleNotFoundError: No module named 'antlr.SwumParser' Failed with exit code 1 rm: output.xml: No such file or directory deleting antlr files... rm: pycache: No such file or directory rm: SwumLexer.interp: No such file or directory rm: SwumLexer.py: No such file or directory rm: SwumLexer.tokens: No such file or directory rm: SwumParser.interp: No such file or directory rm: SwumParser.py: No such file or directory rm: SwumParser.tokens: No such file or directory rm: SwumParserListener.py: No such file or directory rm: SwumParserVisitor.py: No such file or directory (venv) (base) Vaibhavis-MacBook-Pro:swumphrases vaibhaviraut$ ------>>>>>

Also, should the ~/.bashrc file to be modified, be the external one through the system's terminal or through the Pycharm terminal? I tried doing both and tried to re-run the cmd you gave but still getting the same output.

cnewman commented 4 years ago

I helped her fix it.

Thanks @BrianPopeck for helping Vaibhavi out.