Reputation: 185
I am a Django newbie and want to explore the power of this famous framework.
After all setups I ran
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 a workon
command.
Also, when I ran which python
, I got this:
/home/myname/Envs/EnvName/bin/python
,
and pip freeze| grep - django
returns:
Django==1.5.4
django-toolbelt==0.0.1
The first line of my manage.py 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 do see a folder named django.
So I guess I am really stuck, anyone please?
Upvotes: 7
Views: 23630
Reputation: 113
system.
Maybe you already fix it out. But I post this for later fellows.
try:
which python sudo which python
after you see the different. you are able to do:(with you env activated: source activate)
sudo `which python` manage.py shell
hope helps
cheers
Upvotes: 0
Reputation: 2368
This first line its probably making it use your python from /usr/bin/env
.
You could try two things in this case:
1) If you didn't already, you should activate your virtualenv and then install Django:
source /home/myname/Envs/EnvName/bin/activate
pip install django
2) Remove first line of manage.py which I don't thing would be a problem since you are using python manage.py ...
, unless you didn't activated
your virtualenv before.
UPDATE:
There is really nothing more that what it's saying. Python couldn't find django, so you just need to activate
(which I think you already did) and pip install django
.
ANOTHER UPDATE:
Your problem its actually simpler to solve. You are trying sudo python manage.py syncdb
and when you do using sudo you are not accessing python from virtualenv
, so just remove sudo and everything should run.
Upvotes: 8