1

I am facing a problem for two days now but I can't get any answer that works.
I have a project named "ekz" with an app called "welcome", I need to execute the project using apache+wsgi (I am working on osx yosemite). When I run the project using "manage.py runserver" it works fine, but when I run it using apache it gives me the error "No module named ekz.settings" this is the full trace from the apache logs:

mod_wsgi (pid=29210): Target WSGI script '/Users/s2labs/Desktop/ekz/ekz/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=29210): Exception occurred processing WSGI script '/Users/s2labs/Desktop/ekz/ekz/wsgi.py'.
Traceback (most recent call last):
File "/Users/s2labs/Desktop/ekz/ekz/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/conf/__init__.py", line 55, in __getattr__
self._setup(name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/conf/__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named ekz.settings

And here is the wsgi.py file, I didn't modify it, it was created when I created the project using pycharm:

import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()

And here is the configuration of the httpd.conf file, I followed the docs to do that:

Alias /static/ /Users/s2labs/Desktop/ekz/welcome/static/

<Directory /Users/s2labs/Desktop/ekz/welcome/static>
Require all granted
</Directory>

WSGIScriptAlias / /Users/s2labs/Desktop/ekz/ekz/wsgi.py
WSGIPythonPath /Users/s2labs/Desktop/ekz:/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages


<Directory /Users/s2labs/Desktop/ekz/ekz>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

I really appreciate any help, thank you.

Yasser
  • 71
  • 1
  • 6

1 Answers1

0

I hope this helps someone facing this problem. Well, what I did is install the wsgi for python3 and made apache user (www-data) the owner of the directory of my site and all its content, and it worked just fine.

Yasser
  • 71
  • 1
  • 6