I have both python 2.7 and python 3.5 installed on my Ubuntu 16.04 LTS. I have also installed python3-pip to be used for installing external packages to python 3.5.

Using pip3 I have installed django using the following command:

sudo pip3 install django

This command installed the package into the dist-packages directory ar /usr/local/lib/python3.5 on my computer.

I have used similar commands for installing other packages as well.

However when I ran this command after to start a django server :

python3 manage.py runserver

It show 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'

Also when I start python3 onterminal and type:

import django

It too gives an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'django'

I face similar problems with other python packages I have installed using pip3 like BeautifulSoup, xlrd, xlwt, youtube-dl. I can access none of them from python3.

I should also mention that I use Pycharm for Python development. In that, I can access all of these packages and it uses python3.5 as intepreter which is located at /usr/bin/.

My question is how do I solve?

I have tried using simply

pip3 install django

but that gives the following error:

PermissionError: [Errno 13] Permission denied: '/home/rishav/.local/lib/python3.5/site-packages/django'

I have googled this problem and I have not found any viable solution. Please help me resolve this problem.

  • What does python3 -c 'import sys; print(sys.path)' say?
    – edwinksl
    Jul 21, 2016 at 8:17
  • It says : ['', '/usr/local/lib/python35.zip', '/usr/local/lib/python3.5', '/usr/local/lib/python3.5/plat-linux', '/usr/local/lib/python3.5/lib-dynload', '/home/rishav/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/site-packages']
    – Ris97
    Jul 23, 2016 at 7:34

2 Answers 2


Run the follwing:

  1. as mentioned above, you need to apt-get install python-django or python3-django
  2. sudo apt-get install python-pip (or sudo apt-get install python3-pip)
  3. sudo apt-get install mysql-server (I would suggest you do not use sqlite3 if you want to work with databases) (THIS STEP IS OPTIONAL!!!!)
  4. sudo apt-get install apache2 (for django to run on it)

Basic info:

  1. Use django-admin startproject << name >>
  2. Modify the django settings to run on the apache server
  3. You must be inside the project location to be able to run << python manage.py runserver >>
  • I have apache2 installed but when I tried installing mod_wsgi for django to work with apache, the configure script could not find apxs or apxs2.
    – Ris97
    Jul 22, 2016 at 14:01
  • 1
    try this: 1. sudo apt-get install apache2-dev 2. restart the apache service
    – Hellas
    Jul 22, 2016 at 17:29
  • thank you it worked but during 'make' it threw this error: src/server/wsgi_python.h:24:20: fatal error: Python.h: No such file or directory compilation terminated. Sorry to bother you again
    – Ris97
    Jul 23, 2016 at 7:21
  • apt-get install python3-dev or python-dev, that should take care of it; let me know how it goes
    – Hellas
    Jul 23, 2016 at 10:14
  • It worked I could install mod_wsgi but I am having trouble configuring the httpd.conf file for apache2 to run django as I cannot find that file. I have checked at /usr/local/apache2/conf but there is no apache2 folder in usr/local. However when I go to on my browser it shows the "It works!" page. So I am really baffled about my apache2 installation and running django on it.
    – Ris97
    Jul 23, 2016 at 15:42

Well something must have went wrong during that pip3 install. You can also Django like sudo apt-get install python3-django

Cheers [if this helps]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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