Trying to get my django project hosted using apache2 and mod_wsgi. I've tried various configurations, but keep getting import errors when hitting the site in a browser such as:
Traceback (most recent call last):
File "/home/user/projects/my_projectMain/my_project/my_project/wsgi.py", line 19, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python3.4/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'my_project'
Here's my directory structure(/home/user/projects/my_projectMain/):
-- my_projectEnv\ (virtualenv w/ python 3.5.2, django 1.10, django-bootstrap3, django-static-jquery==2.1.4)
-- my_project\
|-- app\
|-- manage.py
|-- static\
|-- my_project\
|-- | -- __init__.py
|-- | -- __pycache__
|-- | -- settings.py
|-- | -- wsgi.py
`-- | -- urls.py
wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings")
application = get_wsgi_application()
/etc/apache2/sites-available/000-default.conf:
...
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
Alias /static /home/user/projects/my_projectMain/my_project/static
<Directory /home/user/projects/my_projectMain/my_project/static>
Require all granted
</Directory>
<Directory /home/user/projects/my_projectMain/my_project/my_project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess my_project python-path=/home/user/projects python-home=/home/user/projects/my_projectMain/my_projectEnv
WSGIProcessGroup my_project
WSGIScriptAlias / /home/user/projects/my_projectMain/my_project/my_project/wsgi.py
...
I'm concerned about my directory structure being the problem, but also have seen a lot of other posts related to the path not being correct in wsgi.py.
EDIT: If I change python-path to:
WSGIDaemonProcess my_project python-path=/home/user/projects/my_projectMain/my_project/my_project
I get:
Traceback (most recent call last):
File "/home/user/projects/my_projectMain/my_project/my_project/wsgi.py", line 25, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python3.4/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python3.4/dist-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'django_static_jquery'
- Does this mean that I've gotten past it not being able to import my_project?
- I've ran collectstatic and ensured that static_jquery is in my STATIC_ROOT, how could it not be able to import that installed app?