import error
The pits that have been stepped on
Setting the _init._py file in the utils folder has this, so importing it still doesn’t work.
import utils.data_augment as dataAug
import utils.tools as tools
debug error reporting
ModuleNotFoundError: No module named ‘utils.data_augment’; ‘utils’ is
not a package
Solution
After setting the directory to source root, import like this.
After setting up, the color of the folder will change and the red line will no longer be needed.
import data_augment as dataAug
import tools as tools
import red line but can still run normally
How to use import
https://zhuanlan.zhihu.com/p/63143493
I just saw the import red line in this blog, but it can run normally and I can’t hold down ctrl to jump to the corresponding function.
Referring to this situation, if m1 import m2 in the same directory
holds down ctrl and clicks m2, it will not jump to it.
Solution: Right-click the directory and set it to Source Root
It can run directly at this time, and there is no red line. Press and hold m2 to jump directly.