Search code examples
pythondjangopycharm

PyCharm Not Properly Recognizing Requirements - Python, Django


Often requirements show up in requirements.txt like this:

django-registration

But in INSTALLED_APPS it appears as registration. So when you import like:

from registration.signals import user_registered

This is valid but PyCharm is showing a red squiggly line under the word registration in from registration... that says "Package 'registration' is not listed in project requirements".

How can I remedy this?

UPDATE

I was able to find a way to make the warning go away but it's not a good solution. If you simply add the package name to the requirements.txt file the warning goes away, but then that requirement is not valid if you were to install with pip. For example, I'm also using pygooglevoice which is how it's written in requirements.txt but when it's imported in the code, you write:

from googlevoice import Voice

This seems weird because I use PyCharm for many projects and I'm just noticing this with a recent project I'm working on...


Solution

  • After seeing this phenomenon again, I did some more digging. After setting certain folders as source roots and restarting PyCharm, these reference warnings went away. I think this is a bug in PyCharm.