I am trying to import a legacy project into pycharm for debugging. The directory structure looks like:
top folder ---> folder one
top folder ---> folder two
The problem is that programs in the sub-folders use:
import top
from top import module
Pycharm returns the error: "No module named top"
How can I fix this?
First thing to make sure is to do what Games said, you need to make sure each folder that is representing a package is done by putting a __init__.py
file which is a empty python file named exactly __init__.py
that tells the interpreter that the folder is a python package.
Second thing to look for is that pycharm likes to complain about imported code if PyCharm does not know about that directory. Go into the Project Interpreter Configuration and go to Paths and add the path references that are not in the project or directly under the interpreter.
One other thing to add, is to set the source root of your project code by right clicking the folder that represents your root and clicking the 'Mark Directory as...' > 'Source Root'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With