I have a bunch of modules. The modules and their imports are listed below:
ast.py:
import enum
from abc import ABC, abstractmethod
err.py:
none
lexer.py:
from token import TokenTag, Token
parser.py:
from ast import *
from err import UndeclaredIdentError, SyntaxError
from token import TokenTag as Tag
from type import Type
peep.py:
from lexer import Lexer
from parser import Parser
token.py:
import enum
treewalker.py:
from abc import ABC, abstractmethod
type.py:
import enum
from treewalker import TreeWalker
I tried to run peep.py but I get the following error:
Traceback (most recent call last):
File "peep.py", line 2, in <module>
from parser import Parser
ImportError: cannot import name 'Parser'
I don't understand why I got ImportError, I can't find any obvious circular dependencies in the file hierachy above. I did some research, I figured that I should rename the module ast.py to syntaxtree.py because ast.py already exists in Python's standard library. After renaming, it produced the same result. Any form of help is appreciated, thanks!
Open parser.py file and change the code for from parser import Parser
to from .parser import Parser
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With