Home > Net >  PyCharm does not see source root
PyCharm does not see source root

Time:01-17

I have marked the folder as source root but PyCharm still is not able to import from there without warnings. In the given picture I am trying to import from the models to the document.py. How can I fix it?

enter image description here

enter image description here

CodePudding user response:

Once you're inside a folder, you don't really see where you are. Source root contains packages and it's not a package on its own, so to be able to import models, you gotta make its parent folder (api) a source root.

This is also better because you have code next to models, in app, and it's part of the source as well. ;)

CodePudding user response:

Models is not a package. Add an empty __init__.py file on it

  •  Tags:  
  • Related