In python project,shows "attempted relative import with no known parent package File"

67 Views Asked by At

**attempted relative import with no known parent package File "C:\Users\Admin\Desktop\gordon\soccer\plugins\my_plugin.py", line 7, in

from  ..public.json.json import JsonCommMgr

ImportError: attempted relative import with no known parent package**

here's directory tree: enter image description here

in json.py , there is defined a class JsonCommMgr, and in my_plugin.py , I wanna use this class JsonCommMgr. and in main.py , I used:

        try:
            plugin_module = importlib.import_module(f'plugins.{plugin_name}')
        ....

main.py only load plugin file my_plugin.py , and execute my_plugin.py's function named run

0

There are 0 best solutions below