I tried to configure WSGI with wsgi.py in my project folder
import os
import sys
sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR']))
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
virtenv = os.environ['OPENSHIFT_HOMEDIR'] + 'python/virtenv/'
os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.7/site-packages')
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
execfile(virtualenv, dict(__file__=virtualenv))
except IOError:
pass
#
# IMPORTANT: Put any additional includes below this line. If placed above this
# line, it's possible required libraries won't be in your searchable path
#
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
but I have Internal Server Error 500
[Wed Jun 08 16:42:46 2016] [error] [client 127.9.155.129] ImportError: No module named project.settings
and I have this module available in my projet.
I tried some help like :
http://www.appsembler.com/blog/django-deployment-using-openshift/
How to configure Django on OpenShift?
Can you help my to launch my app on OpenShift
Thanks
I had on the top of wsgi.py
os.path.join(os.environ['OPENSHIFT_HOMEDIR'], 'app-root/repo')
and I didn't have this error !
And I also put all my code under folder which have the name of my project in order to match
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
Related
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.
I´m making a web app with django, but when I run the application, I´m getting this error:
I have uploaded my client_secrets.json file in the project path and I´m sure I have no typos
Settings.py
GOOGLE_OAUTH2_CLIENT_SECRETS_JSON = 'client_secrets.json'
WSGI.py
# This file contains the WSGI configuration required to serve up your
# web application at http://bohosul02.pythonanywhere.com/
# It works by setting the variable 'application' to a WSGI handler of some
# description.
#
# The below has been auto-generated for your Django project
import os
import sys
# add your project directory to the sys.path
project_home = '/home/bohosul02/misitio'
if project_home not in sys.path:
sys.path.insert(0, project_home)
# set environment variable to tell django where your settings.py is
os.environ['DJANGO_SETTINGS_MODULE'] = 'gfglogin.settings'
# serve django via WSGI
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
You're using a relative path name (client_secrets.json) without paying attention to what your working directory is. If you use the full path to the file, then it will be able to find it.
This seems weird but it has happened a number of times now. I have some artitrary .py file which was just added to the "Project/Project" directory (same directory as my settings.py). 2-3 scripts import from this script.
After adding the script and restarting apache, the django website shows the following errors exclusively:
Error from:
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" %
(self.SETTINGS_MODULE, e))
[Wed Jul 24 08:10:03 2013] [error] [client 127.0.0.1] ImportError:
Could not import settings 'Project.settings' (Is it on sys.path?):
No module named settings
Any advice? Thank you.
Here is a directory repr:
Project/
Project/
__init__.py
settings.py
urls.py
views.py
wsgi.py
something.py
App/
__init__.py
views.py
models.py
tasks.py
I tried to restore the site by removing something.py and its imports, however nothing worked.
UPDATE: in the wsgi.py file I put
print os.getcwd()
# prior to
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Project.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
And the result was off! We were in the wrong directory.
It pointed to /home/user/path/to/django/project instead of /home/user, but however it still
does not work!! Which makes no sense because settings.py is right there, it can blatantly import it..
How come this random scenario caused this?? And previous times it did not.
Can someone please explain? Thanks.
WOW, unbelievable. I accidentally had an extra unneeded init.py inside the main higher level Project folder... This was causing Project.settings to look at the directory one level too high!!
I am trying to load a python wsgi file called from apache with mod_wsgi. My wsgi file attempts to reset the sys.path with:
import os, sys
root = os.path.join(os.path.dirname(__file__), '..')
sys.path.insert(0, root)
Apache complains with:
[Wed Feb 15 19:12:26 2012] [error] [client 127.0.0.1]
ImportError: Could not import settings 'mysite.settings'
(Is it on sys.path?): No module namedmysite.settings`
when I do:
>>> dir('mysite.wsgi')
It becomes apparent the wsgi file does not possess the __file__ attribute, so my sys.path is not getting updated with the necessary directory.
Why would this mysite.wsgi file not have a __file__ attribute?
It should work,
but you can also try and check if following code block helps.
DIRNAME = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(DIRNAME)
The resulting path set to 'root', must be the parent directory of the directory where the Django settings.py is located and 'mysite' must be the name of that directory. You say nothing about the name of your project directory or where the WSGI file is located with respect to it, so not possible to tell you how your code is wrong.
Code under Apache will also run as special user, so project directory must be accessible/readable to that user.
Perhaps go watch:
http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations
to better understand how to set it all up.
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/