skip to Main Content

I know that many have posted similar question however I tried most solution without success.
I’m trying to host a webpage with apache2 and django in python3.

In the error log I found ImportError: No module named 'django' when accessing the wsgi.pyfile, where I also added import sys, sys.version to confirm which python version is used and from the error log I can see that I’m running following python version 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609].

When I run python3.5 I see that I uses the same python version and here I can run import django without any error!

EDIT: I checked django.__file__and saw that it was located in /home/USERNAME/.local/lib/python3.5/site-packages/django/init.py and that path /home/USERNAME/.local/lib/python3.5/site-packages wasn’t in the sys.path that tried to run django. But adding it with sys.path.append(path) didn’t help 🙁

Any thoughts what I might have messed up?

3

Answers


  1. Chosen as BEST ANSWER

    I finally understood how to solve it! first I had to run pip3 uninstall django then run sudo pip3 install django.


  2. If you have Setup the whole configuration in VirtualEnv then , i suggest you to activate it by,

    source /location to /env/bin activate
    pip3 install django=version_id
    

    or pip install django=version id
    if you want to pass version id then its good or it will install the latest django from your repo.
    Now test Django Version there.
    Hope you will no get the error.

    Login or Signup to reply.
  3. Location – means the path where env will be located in project directory, if you have followed the standard installation process of django or else you don’t need, and version id- vesion of django framework.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search