Django: no module named django.core.management

I am new to Django and want to explore the possibilities of this famous structure.

After all the settings, I started

sudo python manage.py syncdb ,

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 

I use virtualenv and virtualenvwrapper and I activated my working virtualenv by issuing the workon command.

Also, when I ran which python , I got the following:

/home/myname/Envs/EnvName/bin/python ,

and pip freeze| grep - django pip freeze| grep - django returns:

 Django==1.5.4 django-toolbelt==0.0.1 

The first line of my manage.py file is #!/usr/bin/env python .

Also

python2.7 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

gives

/home/myname/Envs/EnvName/lib/python2.7/site-packages

and in this directory I see a folder called django.

So, I think I'm really stuck, anyone?

+7
python django
source share
2 answers

This first line probably allows you to use your python from /usr/bin/env .

In this case, you can try two things:

1) If you have not already done so, you must activate your virtualenv and then install Django:

 source /home/myname/Envs/EnvName/bin/activate pip install django 

2) Delete the first line of manage.py which will not be a problem since you are using python manage.py ... unless you have used activated your virtualenv before.


UPDATE:

There is nothing more than what he says. Python could not find django, so you just need to activate (which I think you already did) and pip install django .


OTHER UPDATE:

Your problem is actually actually easier to solve. You are trying sudo python manage.py syncdb , and when you use sudo you are not accessing python from virtualenv , so just uninstall sudo and everything should work.

+8
source share

system.

You may already have fixed it. But I publish this for later kids.

try:

which python sudo which python

after you see another. you can do: (env activated with you: activate the source)

sudo `which python` manage.py shell

hopes help

amuses

0
source share

All Articles