Where is Pip3 Installing Modules?

Zamphatta picture Zamphatta · Nov 25, 2015 · Viewed 49.7k times · Source
  • Ubuntu 15.10
  • Python 3.4.3+
  • Django 1.8.7

When I try to import django in the python3 interpreter, it says ImportError: No module named 'django'. I know Django 1.8.7 installed though, 'cause I can get the version # by doing django-admin --version in the terminal commandline.

When I tried python3 manage.py runserver in a Django project directory, 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'

So again (as expected), it's not in a path where Python can find it.

I looked in /usr/local/lib/python3.4/dist-packages but it's an empty directory.

I did a whereis django & whereis Django and that simply gives me a line with django: or Django: respectively and no list of paths.

I tried Googling how to find path to Django, but that didn't turn up anything useful.

I found & checked the code of the django-admin file itself, but it doesn't have anything indicating where Django installed to. Oddly, the python file imports the django module and it works, even though the interpreter & Django project files can't see the django module. So it's on the python path but it also isn't?!? I don't know, and I can't find it.

I never had a problem like this with a previous Ubuntu (or any other OS). Has anyone got a clue how I can find where Django installed? Actually, I can't find any of the modules I installed via pip3. I've been trying to figure this out for over an hour now, and I'm very confused & frustrated.

Answer

Zartch picture Zartch · Nov 25, 2015

Normally pip 3 install on python3 dist-packages

You can always use pip with:

python3 -m pip install package

to check if you are experiencing troubles with another python3 installation

ls /usr/local/lib | grep python

But the easy way to not experiment this headache is by using virtual environments