简体   繁体   中英

Where is Pip3 Installing Modules?

  • 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.

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

I think you have installed django outside virtual environment. download virtual environment by

pip install virtualenv
virtualenv your_env

Activate virtual environment.

source your_env/bin/activate

Then, Install django in your virtual environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM