Python Forum
import error (unknown location)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
import error (unknown location)
#1
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
Reply
#2
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 6,654 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  Error UserWarning: Unknown option ssl_ca_certs warnings.warn(str(exc)) Vijayaraj 0 715 Jul-11-2023, 06:01 AM
Last Post: Vijayaraj
  import module error tantony 5 3,441 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Cryptic Error with import statement Led_Zeppelin 2 2,536 Jan-11-2022, 01:13 PM
Last Post: Led_Zeppelin
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 10,614 Jan-04-2022, 01:05 PM
Last Post: Anldra12
  Unknown Error with Random Stat Assigner FC8 6 2,301 Dec-06-2021, 01:56 PM
Last Post: FC8
  import module with syntax error Skaperen 7 5,272 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  Import Error Christian 3 3,176 Apr-17-2021, 11:27 PM
Last Post: bowlofred
  Folium import error kashif_flavio 2 3,645 Dec-07-2020, 08:58 AM
Last Post: bowlofred
  Import error Beingcode 0 2,496 Nov-20-2020, 02:57 AM
Last Post: Beingcode

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020