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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With