gunicorn.errors.AppImportError: Failed to find attribute 'app' in 'electricars'

Not sure what is wrong in here:

Running 'gunicorn electricars:app'
Oct 2 11:56:08 AM  Traceback (most recent call last):
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/util.py", line 402, in import_app
Oct 2 11:56:08 AM      app = getattr(mod, name)
Oct 2 11:56:08 AM  AttributeError: module 'electricars' has no attribute 'app'
Oct 2 11:56:08 AM  
Oct 2 11:56:08 AM  During handling of the above exception, another exception occurred:
Oct 2 11:56:08 AM  
Oct 2 11:56:08 AM  Traceback (most recent call last):
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/bin/gunicorn", line 8, in <module>
Oct 2 11:56:08 AM      sys.exit(run())
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
Oct 2 11:56:08 AM      WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/base.py", line 231, in run
Oct 2 11:56:08 AM      super().run()
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/base.py", line 72, in run
Oct 2 11:56:08 AM      Arbiter(self).run()
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/arbiter.py", line 58, in __init__
Oct 2 11:56:08 AM      self.setup(app)
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/arbiter.py", line 118, in setup
Oct 2 11:56:08 AM      self.app.wsgi()
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
Oct 2 11:56:08 AM      self.callable = self.load()
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
Oct 2 11:56:08 AM      return self.load_wsgiapp()
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
Oct 2 11:56:08 AM      return util.import_app(self.app_uri)
Oct 2 11:56:08 AM    File "/opt/render/project/src/.venv/lib/python3.7/site-packages/gunicorn/util.py", line 406, in import_app
Oct 2 11:56:08 AM      raise AppImportError("Failed to find attribute %r in %r." % (name, module))
Oct 2 11:56:08 AM  gunicorn.errors.AppImportError: Failed to find attribute 'app' in 'electricars'.

manage.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'electricars.settings')

application = get_wsgi_application()

render.yaml

services:
  - type: web
    name: electricars
    runtime: python
    buildCommand: pip install -r requirements.txt
    startCommand: "gunicorn electricars.wsgi:application"
    envVars:
      - key: DATABASE_URL
        fromDatabase:
          name: electricars
          property: connectionString
      - key: SECRET_KEY
        generateValue: true
      - key: WEB_CONCURRENCY
        value: 4

Hi there,

I think the problem might be in your render.yaml file: startCommand: "gunicorn electricars.wsgi:application". Try changing this to just gunicorn electricars.wsgi, as it looks like you want to run a WSGI server and not an application file.

Let us know if you have any further questions.

Regards,
Mike


Render Support Engineer, MT (UTC-6)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.