Reputation: 8654
I am trying to install django, but I am not sure how to proceed. I think I have installed django, but python python doesn't seem to be able to seethe package.
$ sudo pip install django
Requirement already satisfied (use --upgrade to upgrade): django in /usr/local/lib/python2.7/site-packages
Cleaning up...
$ python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named django
How do I fix this? When I try to run the server I get this error
$ 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
Upvotes: 3
Views: 5533
Reputation: 124648
Your pip
is using a different version of Python than your python
. Check the output of these commands:
pip -V
python -V
python -c 'import sys; print(sys.path)'
There can be multiple versions of Python and Pip installed in your system.
For example in a Bash shell if you type python
+ Tab a few times it will show you the available Python binaries on your PATH, for example python2.7
, python3.4
, and similarly for pip
+ Tab too.
It depends on your system how to configure correctly so that both python
and pip
are using the same versions.
It would be best to use virtualenv. You wouldn't have such problems, as in a virtualenv your Python version and Pip version would be well synchronized.
Judging by your command output, pip
is using Python 2.7. One quick fix could be to try running Django like this:
python2.7 manage.py runserver
Or, to run the pip
version corresponding to your default Python version.
This "quick fix" is a dirty fix. It would be best to use virtualenv.
Upvotes: 1