Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? --> WSGI.PY file

Viewed 2305

When I try to execute py manage.py runserver I had the following message:

raise ImportError(

Import Error: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? )
2 Answers

I found a lot of possible solutions on the internet. I suggest first try the following:

Go to the wsgi.py file, inside MySite and go to this line:

from django.core.wsgi import get_wsgi_application

Verify that Django is imported. I use Pycharm, the IDE allowed me to import directly from there.

After this I was able to run manage.py

Try to make it in a virtual environment, it will work:

  • First, in cmd type pip install virtualenvwrapper
  • Make a folder in c drive which will consist all of your django projects like C:/Django
  • Then go to cmd and type mkvirtualenv [name you want to give] and then close the cmd
  • Open it again and then navigate to the folder C:/Django then when on that folder type workon [the name which you gave]
  • Finally, install django by the pip command and then runserver
Related