Pycharm error Django is not importable in this environment

Pablo Lorenzo picture Pablo Lorenzo · Dec 8, 2014 · Viewed 49.1k times · Source

I'm getting the following errors in Pycharm.

Error: Django is not importable in this environment

It used to work well but I moved the project and virtualenv to other directory and the error appeared. It's weird because if I run the project ignoring the configuration settings warning that I get, works fine.

The problem is that now, Pycharm is not finding the project interperter.

The command that Pycharm is running is:

/Users/plorenzo/../gestorSchools/venv/bin/python3.4 /Users/plorenzo/../gestorSchools/schoolsManager/manage.py runserver 8000

The virtualenv is activated.

My $PATH is:

/Users/plorenzo/../gestorSchools/venv/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

and my $PYTHONPATH:

/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4

I spent a few days trying to find the solution but I couldn't find it.

Answer

James Bradbury picture James Bradbury · Sep 28, 2015

In my case I had to go to Settings (Alt+F7, or the Spanner/Cog icon) and select a Python interpreter which has Django installed alongside it.

If Django isn't already installed, you should be able to install it via the green + icon (not shown below) once an interpreter has been selected.

enter image description here