Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 961
nicorellius Avatar asked Mar 13 '15 05:03

nicorellius


People also ask

How do I enable Django in PyCharm?

To enable Django support, follow these steps: Open the project Settings/Preferences dialog ( Ctrl+Alt+S ) and navigate to the Languages & Frameworks | Django page. Make sure that the checkbox Enable Django support is selected. Apply changes (if any) and close the dialog.

How does PyCharm detect Django?

If you cannot print the Django version from the python console in Pycharm, go to settings>Project:project_name>project Interpreter and from the list of installed packages see the installed Django and it's version for that project.

Is PyCharm good for Django?

One of the features of PyCharm is that it includes a support for Django. With the ability of including JavaScript features within PyCharm, it can be considered as the best IDE for Django.

Do I have to install Django for every project in PyCharm?

If you are using virtual environment for every new project then you need to install django each time. Other wise you can use single virtual environment for all the project.


1 Answers

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.

like image 170
nicorellius Avatar answered Sep 16 '22 21:09

nicorellius