Django Python mod_wsgi: ImportError: No module named 'django'












0















I'm trying to set up a Django-Python environment in Ubunt16.04u server but I get the Apache error: "ImportError: No module named 'django'"
I've installed Python 3.7, virtualenv (sudo pip install virtualenv), Django (pip install Django), mod_wsgi (sudo make install).



Which could be the reason of the issue?



//Apache Error Log File



[Wed Nov 21 17:45:07.572605 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] mod_wsgi (pid=60818): Target WSGI script '/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py' cannot be loaded as Python module.
[Wed Nov 21 17:45:07.572638 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] mod_wsgi (pid=60818): Exception occurred processing WSGI script '/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py'.
[Wed Nov 21 17:45:07.572758 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] Traceback (most recent call last):
[Wed Nov 21 17:45:07.572805 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] File "/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py", line 17, in <module>
[Wed Nov 21 17:45:07.572812 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] from django.core.wsgi import get_wsgi_application
[Wed Nov 21 17:45:07.572824 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] ImportError: No module named 'django'


//Apache Config File



<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerAdmin webmaster@example.com
ServerName cv-django.vmware
ServerAlias www.cv-django.vmware
DocumentRoot /var/www/django_virtualenv/progetti_django/curriculum/cv
WSGIScriptAlias / /var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py

WSGIDaemonProcess cv-django.vmware processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/djang$
WSGIProcessGroup cv-django.vmware

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

<Directory /var/www/django_virtualenv/progetti_django/curriculum/cv/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>


Alias /static/ /var/www/django_virtualenv/progetti_django/curriculum/cv/static/

<Directory /var/www/django_virtualenv/progetti_django/curriculum/cv/static>
Require all granted
</Directory>

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

ServerSignature On



# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


//wsgi.py



import os
import time
import traceback
import signal
import sys


from django.core.wsgi import get_wsgi_application

sys.path.append('/var/www/django_virtualenv/progetti_django/curriculum/cv')

sys.path.append('/var/www/django_virtualenv/progetti_django/lib/python3.7/site-packages')

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'curriculum.settings')

try:
application = get_wsgi_application()
except Exception:
# Error loading applications
if 'mod_wsgi' in sys.modules:
traceback.print_exc()
os.kill(os.getpid(), signal.SIGINT)
time.sleep(2.5)









share|improve this question























  • Possible duplicate of django apache ImportError: No module named

    – Red Cricket
    Nov 21 '18 at 17:46
















0















I'm trying to set up a Django-Python environment in Ubunt16.04u server but I get the Apache error: "ImportError: No module named 'django'"
I've installed Python 3.7, virtualenv (sudo pip install virtualenv), Django (pip install Django), mod_wsgi (sudo make install).



Which could be the reason of the issue?



//Apache Error Log File



[Wed Nov 21 17:45:07.572605 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] mod_wsgi (pid=60818): Target WSGI script '/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py' cannot be loaded as Python module.
[Wed Nov 21 17:45:07.572638 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] mod_wsgi (pid=60818): Exception occurred processing WSGI script '/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py'.
[Wed Nov 21 17:45:07.572758 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] Traceback (most recent call last):
[Wed Nov 21 17:45:07.572805 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] File "/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py", line 17, in <module>
[Wed Nov 21 17:45:07.572812 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] from django.core.wsgi import get_wsgi_application
[Wed Nov 21 17:45:07.572824 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] ImportError: No module named 'django'


//Apache Config File



<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerAdmin webmaster@example.com
ServerName cv-django.vmware
ServerAlias www.cv-django.vmware
DocumentRoot /var/www/django_virtualenv/progetti_django/curriculum/cv
WSGIScriptAlias / /var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py

WSGIDaemonProcess cv-django.vmware processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/djang$
WSGIProcessGroup cv-django.vmware

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

<Directory /var/www/django_virtualenv/progetti_django/curriculum/cv/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>


Alias /static/ /var/www/django_virtualenv/progetti_django/curriculum/cv/static/

<Directory /var/www/django_virtualenv/progetti_django/curriculum/cv/static>
Require all granted
</Directory>

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

ServerSignature On



# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


//wsgi.py



import os
import time
import traceback
import signal
import sys


from django.core.wsgi import get_wsgi_application

sys.path.append('/var/www/django_virtualenv/progetti_django/curriculum/cv')

sys.path.append('/var/www/django_virtualenv/progetti_django/lib/python3.7/site-packages')

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'curriculum.settings')

try:
application = get_wsgi_application()
except Exception:
# Error loading applications
if 'mod_wsgi' in sys.modules:
traceback.print_exc()
os.kill(os.getpid(), signal.SIGINT)
time.sleep(2.5)









share|improve this question























  • Possible duplicate of django apache ImportError: No module named

    – Red Cricket
    Nov 21 '18 at 17:46














0












0








0








I'm trying to set up a Django-Python environment in Ubunt16.04u server but I get the Apache error: "ImportError: No module named 'django'"
I've installed Python 3.7, virtualenv (sudo pip install virtualenv), Django (pip install Django), mod_wsgi (sudo make install).



Which could be the reason of the issue?



//Apache Error Log File



[Wed Nov 21 17:45:07.572605 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] mod_wsgi (pid=60818): Target WSGI script '/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py' cannot be loaded as Python module.
[Wed Nov 21 17:45:07.572638 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] mod_wsgi (pid=60818): Exception occurred processing WSGI script '/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py'.
[Wed Nov 21 17:45:07.572758 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] Traceback (most recent call last):
[Wed Nov 21 17:45:07.572805 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] File "/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py", line 17, in <module>
[Wed Nov 21 17:45:07.572812 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] from django.core.wsgi import get_wsgi_application
[Wed Nov 21 17:45:07.572824 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] ImportError: No module named 'django'


//Apache Config File



<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerAdmin webmaster@example.com
ServerName cv-django.vmware
ServerAlias www.cv-django.vmware
DocumentRoot /var/www/django_virtualenv/progetti_django/curriculum/cv
WSGIScriptAlias / /var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py

WSGIDaemonProcess cv-django.vmware processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/djang$
WSGIProcessGroup cv-django.vmware

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

<Directory /var/www/django_virtualenv/progetti_django/curriculum/cv/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>


Alias /static/ /var/www/django_virtualenv/progetti_django/curriculum/cv/static/

<Directory /var/www/django_virtualenv/progetti_django/curriculum/cv/static>
Require all granted
</Directory>

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

ServerSignature On



# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


//wsgi.py



import os
import time
import traceback
import signal
import sys


from django.core.wsgi import get_wsgi_application

sys.path.append('/var/www/django_virtualenv/progetti_django/curriculum/cv')

sys.path.append('/var/www/django_virtualenv/progetti_django/lib/python3.7/site-packages')

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'curriculum.settings')

try:
application = get_wsgi_application()
except Exception:
# Error loading applications
if 'mod_wsgi' in sys.modules:
traceback.print_exc()
os.kill(os.getpid(), signal.SIGINT)
time.sleep(2.5)









share|improve this question














I'm trying to set up a Django-Python environment in Ubunt16.04u server but I get the Apache error: "ImportError: No module named 'django'"
I've installed Python 3.7, virtualenv (sudo pip install virtualenv), Django (pip install Django), mod_wsgi (sudo make install).



Which could be the reason of the issue?



//Apache Error Log File



[Wed Nov 21 17:45:07.572605 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] mod_wsgi (pid=60818): Target WSGI script '/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py' cannot be loaded as Python module.
[Wed Nov 21 17:45:07.572638 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] mod_wsgi (pid=60818): Exception occurred processing WSGI script '/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py'.
[Wed Nov 21 17:45:07.572758 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] Traceback (most recent call last):
[Wed Nov 21 17:45:07.572805 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] File "/var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py", line 17, in <module>
[Wed Nov 21 17:45:07.572812 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] from django.core.wsgi import get_wsgi_application
[Wed Nov 21 17:45:07.572824 2018] [wsgi:error] [pid 60818] [remote 192.168.224.1:56398] ImportError: No module named 'django'


//Apache Config File



<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerAdmin webmaster@example.com
ServerName cv-django.vmware
ServerAlias www.cv-django.vmware
DocumentRoot /var/www/django_virtualenv/progetti_django/curriculum/cv
WSGIScriptAlias / /var/www/django_virtualenv/progetti_django/curriculum/curriculum/wsgi.py

WSGIDaemonProcess cv-django.vmware processes=2 threads=15 display-name=%{GROUP} python-home=/var/www/djang$
WSGIProcessGroup cv-django.vmware

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

<Directory /var/www/django_virtualenv/progetti_django/curriculum/cv/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>


Alias /static/ /var/www/django_virtualenv/progetti_django/curriculum/cv/static/

<Directory /var/www/django_virtualenv/progetti_django/curriculum/cv/static>
Require all granted
</Directory>

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

ServerSignature On



# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


//wsgi.py



import os
import time
import traceback
import signal
import sys


from django.core.wsgi import get_wsgi_application

sys.path.append('/var/www/django_virtualenv/progetti_django/curriculum/cv')

sys.path.append('/var/www/django_virtualenv/progetti_django/lib/python3.7/site-packages')

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'curriculum.settings')

try:
application = get_wsgi_application()
except Exception:
# Error loading applications
if 'mod_wsgi' in sys.modules:
traceback.print_exc()
os.kill(os.getpid(), signal.SIGINT)
time.sleep(2.5)






python django






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 17:38









MassimilianoMassimiliano

316




316













  • Possible duplicate of django apache ImportError: No module named

    – Red Cricket
    Nov 21 '18 at 17:46



















  • Possible duplicate of django apache ImportError: No module named

    – Red Cricket
    Nov 21 '18 at 17:46

















Possible duplicate of django apache ImportError: No module named

– Red Cricket
Nov 21 '18 at 17:46





Possible duplicate of django apache ImportError: No module named

– Red Cricket
Nov 21 '18 at 17:46












1 Answer
1






active

oldest

votes


















0














[SOLVED] The error was due to a wsgi python version mismatch. Apache was running a different version (Python 3.5).



I've followed the suggestions in these posts:



https://stackoverflow.com/posts/28118284/revisions



and



Change mod_wsgi from python3.5 to 3.6






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417742%2fdjango-python-mod-wsgi-importerror-no-module-named-django%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    [SOLVED] The error was due to a wsgi python version mismatch. Apache was running a different version (Python 3.5).



    I've followed the suggestions in these posts:



    https://stackoverflow.com/posts/28118284/revisions



    and



    Change mod_wsgi from python3.5 to 3.6






    share|improve this answer




























      0














      [SOLVED] The error was due to a wsgi python version mismatch. Apache was running a different version (Python 3.5).



      I've followed the suggestions in these posts:



      https://stackoverflow.com/posts/28118284/revisions



      and



      Change mod_wsgi from python3.5 to 3.6






      share|improve this answer


























        0












        0








        0







        [SOLVED] The error was due to a wsgi python version mismatch. Apache was running a different version (Python 3.5).



        I've followed the suggestions in these posts:



        https://stackoverflow.com/posts/28118284/revisions



        and



        Change mod_wsgi from python3.5 to 3.6






        share|improve this answer













        [SOLVED] The error was due to a wsgi python version mismatch. Apache was running a different version (Python 3.5).



        I've followed the suggestions in these posts:



        https://stackoverflow.com/posts/28118284/revisions



        and



        Change mod_wsgi from python3.5 to 3.6







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 12:28









        MassimilianoMassimiliano

        316




        316
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417742%2fdjango-python-mod-wsgi-importerror-no-module-named-django%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)