1

I prefer generally to use pip rather than apt-get for installing python modules, as I prefer to separate the packages for Python development from general system packages. However, it seems as though pip won't work for me. I want to install Django, and when I used sudo pip install Django, the installation went through successfully. However, when I opened my Python interpreter REPL, I could not successfully import django - I received an ImportError that Django could not be found. On the other hand, upon running sudo apt install python-django, the installation was successful again, and this time, I could import Django.

So why does this happen? With the pip installation, for some reason, Django was not in /usr/local/lib/python2.7/dist-packages, which is where modules installed with pip go, but django-admin was installed and usable, proving that pip must have installed Django. On the other hand, after installing Django with apt/apt-get, Django folders were existing in /usr/lib/python2.7/dist-packages, where any modules I install with the system package manager are found. I don't know what else I can do to troubleshoot this issue - please tell me if there is anything I am missing and should add.

EDIT I also tried easy_install, which installed to my Python 3.5, and then pip3, and both allowed importing from the Python 3 interpreter. So why doesn't pip for Python 2.7 work in installing Django? I tried another module with pip for 2.7, and everything worked fine. This is just with Django.

1 Answer 1

1

The problem was that my pip was, for some reason, pointing to Python 3.5, even though there was already pip3 for that. I fixed it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .