hi guys.when tried deploy my django site with pythonanywhere i get an error:
here my WSGI configuration file:/var/www/cargoglobal_pythonanywhere_com_wsgi.py:
import os
import sys
path = '/home/cargoglobal/CargoGlobal.net'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'elansayti.settings'
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(get_wsgi_application())
and here my projects wsgi.py:
"""
WSGI config for elansayti project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'elansayti.settings')
application = get_wsgi_application()
please help me guys.i am a very helpless.
Related
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
Kindly help me to find the bug here. Thank you
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()
Complete error
2021-09-18 10:35:44,065: Error running WSGI application
2021-09-18 10:35:44,068: NameError: name 'get_wsgi_application' is not defined
2021-09-18 10:35:44,068: File "/var/www/dhruv354_pythonanywhere_com_wsgi.py", line 30, in <module>
2021-09-18 10:35:44,068: application = get_wsgi_application()
my wsgi.py file
import os
import sys
path = '/home/dhruv354/Django-grocery/'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'ReadingRight.settings'
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(get_wsgi_application())
Everything seems fine to me but still it is giving this error, needs help
I'm trying to setup a Django site on Heroku. I get this error message:
2017-10-07T21:03:33.416585+00:00 app[web.1]:
django.core.exceptions.ImproperlyConfigured: Requested setting
LOGGING_CONFIG, but settings are not configured. You must either define
the environment variable DJANGO_SETTINGS_MODULE or call
settings.configure() before accessing settings.
But if I run Heroku config, the var is set. Why is it not recognized?
=== dagenssalg Config Vars
DISABLE_COLLECTSTATIC: 0
LOGGING_CONFIG: off
Many answers in here mention the wsgi.py file, but I can't see anything wrong with that:
import os
from django.core.wsgi import get_wsgi_application
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
os.environ.setdefault("DJANGO_SETTINGS_MODULE","dagenssalg.settings")
application = get_wsgi_application()
Any help is most appreciated. Best regards Kresten
Your wsgi file is a mess. You import get_wsgi_application twice, then call it before setting the environment variable; you then correctly wrap the application instance with WhiteNoise, but then throw away this instance by calling get_wsgi_application again.
Replace the whole thing with this:
import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE","dagenssalg.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
uwsgi.ini
[uwsgi]
vhost = true
plugin = python
socket = /tmp/pjwards.sock
master = true
enable-threads = true
processes = 2
wsgi-file = /home/ubuntu/workspace/ward/www/fb_archive/wsgi.py
virtualenv = /home/ubuntu/.virtualenvs/fb_archive
chdir = /home/ubuntu/workspace/ward/www/fb_archive
touch-reload = /home/ubuntu/workspace/ward/www/reload
wsgi.py
import site
import os
import sys
from django.core.wsgi import get_wsgi_application
from mezzanine.utils.conf import real_project_name
site.addsitedir('/home/ubuntu/.virtualenvs/fb_archive/lib/python3.4/site-packages')
sys.path.insert(0, '/home/ubuntu/workspace/ward')
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"%s.settings" % real_project_name("fb_archive"))
application = get_wsgi_application()
uWSGI does not work by ImportError: No module named django.core.wsgi.
I use nginx, uwsgi and virtualenv with python3.
Traceback (most recent call last):
File "/home/ubuntu/workspace/ward/www/fb_archive/wsgi.py", line 13, in <module>
from django.core.wsgi import get_wsgi_application
ImportError: No module named django.core.wsgi
unable to load app 0 (mountpoint='') (callable not found or import error)
You're doing the import before you've added your virtualenv to the pythonpath, so naturally the module can't be found. Move the import to just before the get_wsgi_application() call itself.
What is the proper way to deploy a Pyramid project to dotcloud?
The contents of wsgi.py:
import os, sys
from paste.deploy import loadapp
current_dir = os.path.dirname(__file__)
application = loadapp('config:production.ini', relative_to=current_dir)
I'm currently getting the following error.
uWSGI Error
wsgi application not found
This could indicate that wsgi.py could not be imported successfully.
You can check the following:
output of dotcloud logs appname.servicename
log into the service with dotcloud ssh appname.servicename, then go to the current directory, start python and see what happens if you try to do from wsgi import application
If that can help, here is a super-simple Pyramid app:
https://github.com/jpetazzo/pyramid-on-dotcloud
I was able to get pass the uWSGI Error error using :
import os
from paste.deploy import loadapp
current_dir = os.getcwd()
application = loadapp('config:production.ini', relative_to=current_dir)
I still had a path problem with the static files so I changed:
config.add_static_view('static', 'static', cache_max_age=3600)
to
config.add_static_view('<myapp>/static', 'static', cache_max_age=3600)
try this:
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'hellodjango.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
http://docs.dotcloud.com/tutorials/python/django/