Have you experienced the thing I have done like the following.

606 views
Skip to first unread message

Sangbom Suhk

unread,
Mar 26, 2021, 9:36:43 AM3/26/21
to Django users
Hi guyes!

Now I'm trying to install django framework and make python-based web. For this purpose, I installed apache2, python3.8.5 and libapache2-mod-wsgi-py3, and set a virtual host according to the django guide document.  My work flow was like the following. 

1. apt install apache2 apache2-dev libapache2-mod-wsgi-py3
2. apt install build-essential net-tools curl git software-properties-common python3
3. configured virtual host according to django guide document.
4. On my local account, I created virtualenv my domain under /var/www directory.
5. And I installed django, create django_app project like this "django-admin startproject django_app .".
6. And migrate my django project.
7. Next I browsed my site enagape.net, but I encountered the following errors. 

mod_wsgi (pid=5672): Failed to exec Python script file '/var/www/enagape.net_git/django_app/wsgi.py'.
mod_wsgi (pid=5672): Exception occurred processing WSGI script '/var/www/enagape.net_git/django_app/wsgi.py'.
Traceback (most recent call last):
  File "/var/www/enagape.net_git/django_app/wsgi.py", line 18, in <module>
    application = get_wsgi_application()
  File "/usr/lib/python3/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/usr/lib/python3/dist-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django_app'

Help me.

Mr. X Offencer

unread,
Mar 26, 2021, 10:37:08 AM3/26/21
to django...@googlegroups.com
Are you running your  manage.py runserver command in right directory

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/de43f585-89e1-42c6-bc88-f518fa5d7fd1n%40googlegroups.com.

Sangbom Suhk

unread,
Mar 26, 2021, 10:43:19 AM3/26/21
to Django users
Yes, I did. It's work fine.

2021년 3월 26일 금요일 오후 11시 37분 8초 UTC+9에 mr.xof...@gmail.com님이 작성:

Sangbom Suhk

unread,
Mar 26, 2021, 10:49:50 AM3/26/21
to Django users
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
March 26, 2021 - 23:48:29
Django version 3.1.7, using settings 'django_app.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

2021년 3월 26일 금요일 오후 11시 43분 19초 UTC+9에 Sangbom Suhk님이 작성:

Kasper Laudrup

unread,
Mar 26, 2021, 8:09:25 PM3/26/21
to django...@googlegroups.com
On 26/03/2021 13.34, Sangbom Suhk wrote:
> ModuleNotFoundError: No module named 'django_app'
>

Without being an expert on the details, it seems like the WSGI module
cannot find your Django application.

What's in your .wsgi file?

Maybe this could help:

https://www.thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/

Kind regards,

Kasper Laudrup

OpenPGP_signature

Kasper Laudrup

unread,
Mar 26, 2021, 8:10:31 PM3/26/21
to django...@googlegroups.com
On 26/03/2021 15.35, Mr. X Offencer wrote:
> Are you running your  manage.py runserver command in right directory
>

That is probably not relevant as it seems like Sangbom is having issues
with deploying his application, not running the development server.

Kind regards,

Kasper Laudrup

OpenPGP_signature

Sangbom Suhk

unread,
Mar 26, 2021, 11:51:11 PM3/26/21
to Django users
My wsgi.py content is like this

"""
WSGI config for django_app project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
"""

import os

from django.core.wsgi import get_wsgi_application
"""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_app.settings')
"""
os.environ["DJANGO_SETTINGS_MODULE"] = "django_app.settings"

application = get_wsgi_application()

2021년 3월 27일 토요일 오전 9시 9분 25초 UTC+9에 Kasper Laudrup님이 작성:

Sangbom Suhk

unread,
Mar 27, 2021, 1:17:01 AM3/27/21
to Django users
Huray I resolve my problem!

I found the solution from googling.

Thanks.

2021년 3월 27일 토요일 오후 12시 51분 11초 UTC+9에 Sangbom Suhk님이 작성:

Kasper Laudrup

unread,
Mar 27, 2021, 11:58:44 AM3/27/21
to django...@googlegroups.com
On 27/03/2021 06.17, Sangbom Suhk wrote:
> Huray I resolve my problem!
>
> I found the solution from googling.
> https://stackoverflow.com/questions/24122175/django-mod-wsgi-exception-occurred-processing-wsgi-script
>

Glad to hear you figured it out. Thanks for sharing the solution.

Kind regards,

Kasper Laudrup

OpenPGP_signature
Reply all
Reply to author
Forward
0 new messages