I deployed a python module for web on my python project. The module(callback.py) can't import the class in a module on parent directory(logger.py). But it can import the class in another module(storekeeper.py) and the simple module(settings.py).
How can callback.py import Logger class in logger.py?
I got the message below.
Traceback (most recent call last):
File "web\callback.py", line 21, in <module>
from logger import Logger
ImportError: cannot import name 'Logger'
My project:
project
|-module
|-web
|-__init__.py
|-callback.py
|-__init__.py
|-base.py
|-logger.py
|-settings.py
|-storekeeper.py
callback.py:
#!/usr/bin/python3
import cgi
import os
import sys
sys.path.append(os.curdir)
import settings
from io import StringIO
from storekeeper import StoreKeeper
from logger import Logger
class Callback:
@classmethod
def main(cls):
try:
# some code
except Exception as e:
sys.stdout = StringIO()
Logger.alert(str(e))
if __name__ == '__main__':
Callback.main()
logger.py
from base import Base
class Logger(Base):
def __init__(self):
Base.__init__(self)
@classmethod
def alert(cls, subj):
# some code
storekeeper.py
class StoreKeeper:
def __init__(self):
self.__dic = None
def get(self, key):
# some code