Search code examples
pythonpycharm

Pycharm doesnt recognize project packages


Pycharm doesn't recognize the packages of my project's modules.

enter image description here

I noticed there are already quite some questions on this, but I tried all the given solutions and nothing works.

I tried:
- Mark directory as source root & checking Add sources root to pythonpath
- Opening a different project and then reopening the original one to make pycharm reindex the packages

Any suggestions?

I went over the following questions
PyCharm does not recognize modules installed in development mode
Pycharm not recognizing packages even when __init__.py exits


Solution

  • Ok it is quite funny to answer my own question, but I understood that is the encouraged way to go if you actually found the answer.

    So what was causing this problem was that __init__.py was listed as a text file in Pycharm settings.

    If you go to Settings | File Types | Select Text you see a list of file names/extensions that Pycharm recognizes as text.

    enter image description here

    I think this happened because I created a file named __init__ without file extension, and later changed it to __init__.py

    Removing it from there fixed the issue.