1

I have deployed Django app in Wamp server which was working fine. Unfortunately after running pip install Wamp server stopped serving Django applicaiton and throwing below error

 mod_wsgi (pid=26240): Target WSGI script 'D:/testdeployment/mysite/mysite/wsgi.py' cannot be loaded as Python module.
 mod_wsgi (pid=26240): Exception occurred processing WSGI script 'D:/testdeployment/mysite/mysite/wsgi.py'.
 Traceback (most recent call last):
 File "D:/testdeployment/mysite/mysite/wsgi.py", line 16, in <module>
 application = get_wsgi_application()
 File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\core\\wsgi.py", line 13, in get_wsgi_application
 django.setup()
 File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\__init__.py", line 17, in setup
 configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
 File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\conf\\__init__.py", line 55, in __getattr__
 self._setup(name)
 File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\conf\\__init__.py", line 43, in _setup
 self._wrapped = Settings(settings_module)
 File "C:\\Python27\\lib\\site-packages\\django-1.9.4-py2.7.egg\\django\\conf\\__init__.py", line 99, in __init__
       mod = importlib.import_module(self.SETTINGS_MODULE)
     File "C:\\Python27\\Lib\\importlib\\__init__.py", line 37, in import_module
       __import__(name)
   ImportError: No module named mysite.settings

WSGI.PY

  import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

application = get_wsgi_application()

Wamp configuration:

WSGIScriptAlias / "D:/testdeployment/mysite/mysite/wsgi.py"
WSGIPythonPath "D:/testdeployment/mysite/mysite/"


<Directory "D:/testdeployment/mysite/mysite/">
    Order deny,allow
    Allow from all
    Require all granted
</Directory>



<Directory "D:/testdeployment/mysite/mysite/">
        <Files wsgi.py>
            Require all granted
        </Files>
        SSLOptions +StdEnvVars
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require local
</Directory>

Please let me know what is the issue here

niran
  • 1,920
  • 8
  • 34
  • 60
  • Problem has been solved here: [enter link description here](https://stackoverflow.com/questions/36210686/importerror-no-module-named-mysite-settings-django/36211423) – Fiifi Danso Feb 19 '18 at 12:26
  • Problem has been solved here. It worked for me: https://stackoverflow.com/questions/36210686/importerror-no-module-named-mysite-settings-django/36211423 – Fiifi Danso Feb 19 '18 at 12:28

2 Answers2

0

The python path should be the outer mysite directory (the one containing manage.py), not the inner mysite directory (the one containing settings.py and wsgi.py).

WSGIPythonPath "D:/testdeployment/mysite/"

See the Django docs for deploying with Apache and mod_wsgi for more info.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • That sounds like a separate issue, I can't help with that. – Alasdair Dec 18 '17 at 14:06
  • Actually when point to simple empty project I am able to see default Django page, however when I point real project nothing is loading – niran Dec 18 '17 at 16:26
0

I had the same problem but when i looked the locations of files through file explorer , i got to know that i have the files placed inaccurately, like the django searchers for mysite.settings but i have folder called mysite and in that folder i have my mysite file, so the django couldn't find my file. try looking at the file arrangement.