I have an application at work that is set up with the following structure.
/project_root
/applications
/app1
__init__.py
/app2
__init__.py
...
/appN
/pkg
/database
__init__.py
/toolbox
__init__.py
...
__init__.py
__init__.py
main_framework.py
I'm investigating using PyCharm (community edition), instead of Eclipse's PyDev tool. In __init__.py in app1 I have an import statement that looks like this:
import pkg.database
PyCharm complains about the import with a no module named pkg message.
(click for larger image)
Due to how the framework is built, though, the system runs just fine. Each of the appNs know about the pkg directory. How do I inform PyCharm that I have custom built modules in the pkg directory so that these warnings stop?
I am testing PyCharm 4.0.3 Community Edition.
A couple things I've tried, thanks for comments below, that haven't helped:
pkg directory so that it is listed as well. This had no effect.__init__.py in pkg when displaying the structure. This file does exist.The solution to this was a two step process:
pkg directory as a source root. Do this by selecting File -> Settings -> Project -> (select the project) -> Project Structure then select the pkg directory and add by clicking the Sources button. Click Ok.File -> Invalidate Caches / Restart -> Invalidate and Restart
Wait for PyCharm to restart and rebuild it's cache / scan the indexes. Now the pkg directory is detected as a source root and my errors are gone.
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