title: Django Wsgi ModuleNotFoundError: No module named 'project_name'
body: <p>I am trying to deploy a Django project using WSGI and NGINX. The problem is that at startup, the logs show a module missing error</p>
  <p>When launched via the <code>service uwsgi restart</code> command, an error appears in the logs /var/log/uwsgi/app/django.log:</p>
  <pre><code>Wed Aug 18 17:25:21 2021 - Python version: 3.8.10 (default, Jun  2 2021, 10:49:15)  [GCC 9.4.0]
  Wed Aug 18 17:25:21 2021 - *** Python threads support is disabled. You can enable it with --enable-threads ***
  Wed Aug 18 17:25:21 2021 - Python main interpreter initialized at 0x55f90e1e7700
  Wed Aug 18 17:25:21 2021 - your server socket listen backlog is limited to 100 connections
  Wed Aug 18 17:25:21 2021 - your mercy for graceful operations on workers is 60 seconds
  Wed Aug 18 17:25:21 2021 - mapped 145840 bytes (142 KB) for 1 cores
  Wed Aug 18 17:25:21 2021 - *** Operational MODE: single process ***
  Traceback (most recent call last):
    File &quot;project_name/wsgi.py&quot;, line 16, in &lt;module&gt;
      application = get_wsgi_application()
    File &quot;/usr/local/lib/python3.8/dist-packages/django/core/wsgi.py&quot;, line 12, in get_wsgi_application
      django.setup(set_prefix=False)
    File &quot;/usr/local/lib/python3.8/dist-packages/django/__init__.py&quot;, line 19, in setup
      configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
    File &quot;/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py&quot;, line 82, in __getattr__
      self._setup(name)
    File &quot;/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py&quot;, line 69, in _setup
      self._wrapped = Settings(settings_module)
    File &quot;/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py&quot;, line 170, in __init__
      mod = importlib.import_module(self.SETTINGS_MODULE)
    File &quot;/usr/lib/python3.8/importlib/__init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1014, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 991, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 961, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 219, in _call_with_frames_removed
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1014, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 991, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 961, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 219, in _call_with_frames_removed
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1014, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 991, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 973, in _find_and_load_unlocked
  ModuleNotFoundError: No module named 'project_name'
  Wed Aug 18 17:25:22 2021 - unable to load app 0 (mountpoint='') (callable not found or import error)
  Wed Aug 18 17:25:22 2021 - *** no app loaded. going in full dynamic mode ***
  Wed Aug 18 17:25:22 2021 - *** uWSGI is running in multiple interpreter mode ***
  Wed Aug 18 17:25:22 2021 - spawned uWSGI master process (pid: 223091)
  Wed Aug 18 17:25:22 2021 - spawned uWSGI worker 1 (pid: 223102, cores: 1)
  </code></pre>
  <p>wsgi.py:</p>
  <pre><code>import os
  
  from django.core.wsgi import get_wsgi_application
  
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_name.settings.production')
  
  application = get_wsgi_application()
  </code></pre>
  <p>/etc/uwsgi/apps-enabled/django.ini:</p>
  <pre><code> [uwsgi]
      chdir = /root/project_name
      env = DJANGO_SETTINGS_MODULE=project_name.settings.production
      wsgi-file = project_name/wsgi.py
      workers = 1
      plugins = python3
  </code></pre>
  <p>wsgi.py</p>
  <pre><code>import os
  
  from django.core.wsgi import get_wsgi_application
  
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_name.settings.production')
  
  application = get_wsgi_application()
  </code></pre>
  <p>.
  structure /root/project_name/..</p>
  <pre><code>    ├── project_name
      │   ├── asgi.py
      │   ├── __init__.py
      │   ├── settings
      │   │   ├── base.py
      │   │   ├── development.py
      │   │   ├── __init__.py
      │   │   ├── production.py
      │   ├── urls.py
      │   └── wsgi.py
      ├── manage.py
      ├── web_site
      │   ├── admin.py
      │   ├── apps.py
      │   ├── __init__.py
      │   ├── models.py
      │   └── views.py
  </code></pre>
  <p>Because of what could this be? How to fix it?</p>