Python Forum

Full Version: import error (unknown location)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi I've been reading this blog on how to write your own compiler using python but I'm stuck.
in the parser section of the blog after writing all the code and trying to run python main.py I get this error:
Quote:C:\ProgramData\Miniconda3\python.exe C:\Users\mohse\PycharmProjects\ebnf\main.py
Traceback (most recent call last):
File "C:\Users\mohse\PycharmProjects\ebnf\main.py", line 2, in <module>
from parser import Parser
ImportError: cannot import name 'Parser' from 'parser' (unknown location)

Process finished with exit code 1

according to this thread it seems like a problem with newer versions of python. but I'm a python noobie. honestly i didn't get most of it but basically I have to make python find Parser but don't know how...

anybody has any suggestions?

ps: I'm used to programming environments but mostly C# so I can understand you if you make it simple Cool
fixed the problem. easier than i thought must be one of those days :D
you can't use the name parser for your file. it creates a naming conflict

i get the output 6 as expected but i also get an error:
Quote:C:\Users\mohse\PycharmProjects\ebnf\analyzer.py:37: ParserGeneratorWarning: 4 shift/reduce conflicts
return self.pg.build()