running gunicorn mapping to myproject/wsgi.py

I’m trying to setup gunicorn on an Azure VM but there is no .wsgi file for me to run : gunicorn -c gunicorn_config.py myproject.wsgi

gunicorn -c gunicorn_config.py myproject/wsgi.py

[2024-09-13 17:09:49 +0530] [595264] [INFO] Starting gunicorn 23.0.0
[2024-09-13 17:09:49 +0530] [595264] [INFO] Listening at: http://127.0.0.1:8000 (595264)
[2024-09-13 17:09:49 +0530] [595264] [INFO] Using worker: gthread
[2024-09-13 17:09:49 +0530] [595265] [INFO] Booting worker with pid: 595265
[2024-09-13 17:09:49 +0530] [595265] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/var/www/myproject/env/lib/python3.11/site-packages/gunicorn/util.py", line 370, in import_app
    mod = importlib.import_module(module)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'myproject/wsgi'
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "/var/www/myproject/env/lib/python3.11/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
    worker.init_process()
  File "/var/www/myproject/env/lib/python3.11/site-packages/gunicorn/workers/gthread.py", line 94, in init_process
    super().init_process()
  File "/var/www/myproject/env/lib/python3.11/site-packages/gunicorn/workers/base.py", line 135, in init_process
    self.load_wsgi()
  File "/var/www/myproject/env/lib/python3.11/site-packages/gunicorn/workers/base.py", line 147, in load_wsgi
    self.wsgi = self.app.wsgi()
                ^^^^^^^^^^^^^^^
  File "/var/www/myproject/env/lib/python3.11/site-packages/gunicorn/app/base.py", line 66, in wsgi
    self.callable = self.load()
                    ^^^^^^^^^^^
  File "/var/www/myproject/env/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 57, in load
    return self.load_wsgiapp()
           ^^^^^^^^^^^^^^^^^^^
  File "/var/www/myproject/env/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 47, in load_wsgiapp
    return util.import_app(self.app_uri)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/myproject/env/lib/python3.11/site-packages/gunicorn/util.py", line 374, in import_app
    raise ImportError(msg % (module.rsplit(".", 1)[0], obj))
ImportError: Failed to find application, did you mean 'myproject/wsgi:application'?
[2024-09-13 17:09:49 +0530] [595265] [INFO] Worker exiting (pid: 595265)
[2024-09-13 17:09:49 +0530] [595264] [ERROR] Worker (pid:595265) exited with code 3
[2024-09-13 17:09:49 +0530] [595264] [ERROR] Shutting down: Master
[2024-09-13 17:09:49 +0530] [595264] [ERROR] Reason: Worker failed to boot.

Please post your gunicorn_config.py file.

Also, note:

but:

import multiprocessing

bind = "127.0.0.1:8000"  # Replace with your desired IP and port
workers = multiprocessing.cpu_count() * 2 + 1
worker_class = "gthread"
threads = 2
timeout = 60

Nginx is running in front.

I think we were cross-posting - see my previous reply.

So it is not necessary for there to be a myproject.wsgi file is there ?

The reference to myproject.wsgi in the command line:

Is not a reference to a file. It’s a reference to a module.

See the docs at Running Gunicorn — Gunicorn 23.0.0 documentation