Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've installed Django multiple ways, via apt-get and pip install. They all say I have the most recent version of Django. Now whenever I run python in Terminal and type in import django, I receive

ImportError: No module named django

However, when I run django-admin --version I receive


I know it's installed, but why is python not finding the django module?

share|improve this question
Did you install Python manually? – Ignacio Vazquez-Abrams Feb 2 '13 at 4:35
To be honest, I don't remember. – jason328 Feb 2 '13 at 20:29

python is not finding django because it's not on its path. You can see the list of paths python looks for modules like this:

$ python
>>> import sys
>>> sys.path

You can import django if you find the location it is installed, and add that location to python's path, for example like this:

$ PYTHONPATH=/path/to/django/parent/dir python
>>> import django  # should work now

But your real problem is that something's wrong with your python installation. If you have installed both python AND django using apt-get, then django should certainly be on python's path without dirty hacks like above.

That said, when working with Django, your best bet is to NOT use apt-get but create a virtual environment using virtualenv (you can install virtualenv itself using apt-get), and install Django and other modules your Django site might need using pip within the virtual environment. That way you can have multiple Django projects side by side, with precisely the Python modules and versions it requires. It's just a few extra steps to do, but definitely worth it and will save you from much frustration in the future.

share|improve this answer
You can also add to the path directly in your code by using sys.path.append('path/to/django'), then import as normal – NGRhodes Jun 6 '14 at 7:40
@NGRhodes Hardcoding paths in code is not a good idea. – janos Jun 6 '14 at 11:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.