import import problem solving attempted relative import with no known parent package No module named 'E_Attention

Problem Description:

I want to import the class method ECAAttention in ECA.py in the E_Atention directory of the same directory as nets in Mobilenetv3.py under the nets directory folder

Catalog picture display:

The import method used: It feels that everything is normal but it is an error

 import error

 Error type can't find module

solution:

Mark the upper level directory of "nets", which is the directory pointed by the green arrow in the above figure, as the source root directory - right click on the directory 

 

 Mark it as the source root, so that no error will be reported and it can be called normally.

Guess you like

Origin blog.csdn.net/P13643822101/article/details/126301263