I can create a project with django-admin.py startproject
within a virtualenv. But when I try to run server with python manage.py runserver
, I get an error:
(check)robin@robin-VirtualBox:~/checking$ python manage.py runserver
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
But I can run the server when I deactivate the environment and run the it from the project directory. Please help how to solve this. Thank you.
(check)robin@robin-VirtualBox:~/checking$ pip freeze
argparse==1.2.1
wsgiref==0.1.2
Most likely, you have not installed django in the virtual environment.
Either install django in virtual environment. Activate the environment and then install django using pip
or other methods.
Or link/copy django installed on the system (somewhere in /usr/lib/python-XXX
) to python site packages in the environment. No recommended.
from the output of pip freeze
you don't have Django
installed in your virtual environment
run pip install django
Maybe the Django has lost some plugin with pip, so we can install Django with Tarball:
- Go https://www.djangoproject.com/download/1.6.5/tarball/
- Download Django-*.tar.gz
install it.
$ tar zxvf Django-1.6.5.tar.gz
$ cd Django-1.6.5/
$ python setup.py install