I'm trying to run python manage.py runserver
on a Django application I have and I get this error:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
Here is the output of pip freeze | grep -i django
to show I do in fact have Django installed:
Django==1.6.5
django-cached-authentication-middleware==0.2.0
django-cors-headers==1.1.0
django-htmlmin==0.7.0
django-static-precompiler==0.9
djangorestframework==2.3.14
Also, trying to run /usr/local/bin/python2.7 manage.py runserver
yields the same error.
To fix my problem I used the following line in my .zprofile:
I was trying to import Django and it couldn't be found, and doing the above solved the issue.
The direct problem is that django package is missing. For me, as I was running django in virtualenv, this problem occurs after I rename my working directory.
Reinstalling the env worked for me.
I found that I could import the django module from the python interpreter, but django-admin.py could not import it when run from the command line.
I confirmed that I was using the python interpreter in my virtual environment.
I was using a 64-bit version of python. Uninstalling, and installing the 32-bit version, then re-creating my venv solved this for me.
in where your django file resides, check the first line of django-admin.py:
If you use python 3+,
python
here may refers python2 here. So check which python you install django with.If you do have python3 installed and not linked as
python
, change the first shebang line intoi solved this problem by installing django inside the virtual enviromment that i was working on
If you use
virtualenv
and runmanage.py runserver
in windows system, cmd will use system's python, not the python in virtualenv. Because If you installpython
in system, cmd will automatically usepython
that installed in system, not the python invirtualenv
. So if you usevirtualenv
in Windows. you need run