Toufiqur Rahman
Toufiqur Rahman

Reputation: 212

Error running WSGI application in Pythonanywhere

I have researched a lot and found this is a very common question. But the fact is I believe somehow pythonanywhere can not detect my settings.py file. Moreover, I have checked with the settings file directory and it is the same path as I have input in the WSGI file. I have also installed the required pip files but still getting the same errors.

Error running WSGI application

ModuleNotFoundError: No module named 'widget_tweaks'

File "/var/www/ewallet_pythonanywhere_com_wsgi.py", line 33, in <module>

application = get_wsgi_application()

File "/home/ewallet/.virtualenvs/myenv/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
     django.setup(set_prefix=False)

File "/home/ewallet/.virtualenvs/myenv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
     apps.populate(settings.INSTALLED_APPS)

File "/home/ewallet/.virtualenvs/myenv/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)

File "/home/ewallet/.virtualenvs/myenv/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)

Here is the wsgi.py

import os
import sys

path = '/home/ewallet/E-wallet/ewallet/ewallet/'
if path not in sys.path:
    sys.path.append(path)

from django.core.wsgi import get_wsgi_application

os.environ['DJANGO_SETTINGS_MODULE'] = 'ewallet.settings'

application = get_wsgi_application()

Here is the directory image enter image description here

Kindly help me to find the bug here. Thank you

Upvotes: 0

Views: 1716

Answers (1)

Dostonbek Tilavov
Dostonbek Tilavov

Reputation: 11

You just entered path incorrectly. It should be as following:

path = '/home/ewallet/E-wallet/ewallet

So, correct version of your wsgi.py is as following:

import os
import sys

path = '/home/ewallet/E-wallet/ewallet/ewallet/'
if path not in sys.path:
    sys.path.append(path)

from django.core.wsgi import get_wsgi_application

os.environ['DJANGO_SETTINGS_MODULE'] = 'ewallet.settings'

application = get_wsgi_application()

Upvotes: 1

Related Questions