title: Unable to bind Django application with Gunicorn
body: <p>It has been very difficult for me trying to deploy to aws EC2 ubuntu server SINCE I'm coming from windows background. I encounter an error while trying to bind django application to gunicorn. The command I'm running is <code>sudo gunicorn --bind 0.0.0.0:8000 logistics.wsgi:application</code> And the error log is show below:</p>
  <pre><code>(venv) ubuntu@ip-172-31-18-196:/var/www/html$ sudo gunicorn --bind 0.0.0.0:8000 logistics.wsgi:application
  [2021-09-08 11:21:00 +0000] [29379] [INFO] Starting gunicorn 20.1.0
  [2021-09-08 11:21:00 +0000] [29379] [INFO] Listening at: http://0.0.0.0:8000 (29379)
  [2021-09-08 11:21:00 +0000] [29379] [INFO] Using worker: sync
  [2021-09-08 11:21:00 +0000] [29382] [INFO] Booting worker with pid: 29382
  [2021-09-08 11:21:00 +0000] [29382] [ERROR] Exception in worker process
  Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.5/dist-packages/gunicorn/arbiter.py&quot;, line 589, in spawn_worker
      worker.init_process()
    File &quot;/usr/local/lib/python3.5/dist-packages/gunicorn/workers/base.py&quot;, line 134, in init_process
      self.load_wsgi()
    File &quot;/usr/local/lib/python3.5/dist-packages/gunicorn/workers/base.py&quot;, line 146, in load_wsgi
      self.wsgi = self.app.wsgi()
    File &quot;/usr/local/lib/python3.5/dist-packages/gunicorn/app/base.py&quot;, line 67, in wsgi
      self.callable = self.load()
    File &quot;/usr/local/lib/python3.5/dist-packages/gunicorn/app/wsgiapp.py&quot;, line 58, in load
      return self.load_wsgiapp()
    File &quot;/usr/local/lib/python3.5/dist-packages/gunicorn/app/wsgiapp.py&quot;, line 48, in load_wsgiapp
      return util.import_app(self.app_uri)
    File &quot;/usr/local/lib/python3.5/dist-packages/gunicorn/util.py&quot;, line 359, in import_app
      mod = importlib.import_module(module)
    File &quot;/usr/lib/python3.5/importlib/__init__.py&quot;, line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 986, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 969, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 958, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 673, in _load_unlocked
    File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 665, in exec_module
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 222, in _call_with_frames_removed
    File &quot;/var/www/html/logistics/wsgi.py&quot;, line 12, in &lt;module&gt;
      from django.core.wsgi import get_wsgi_application
    File &quot;/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py&quot;, line 2, in &lt;module&gt;
      from django.core.handlers.wsgi import WSGIHandler
    File &quot;/usr/local/lib/python3.5/dist-packages/django/core/handlers/wsgi.py&quot;, line 3, in &lt;module&gt;
      from django.conf import settings
    File &quot;/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py&quot;, line 19, in &lt;module&gt;
      from django.utils.deprecation import RemovedInDjango40Warning
    File &quot;/usr/local/lib/python3.5/dist-packages/django/utils/deprecation.py&quot;, line 5, in &lt;module&gt;
      from asgiref.sync import sync_to_async
    File &quot;/usr/local/lib/python3.5/dist-packages/asgiref/sync.py&quot;, line 115
      launch_map: &quot;Dict[asyncio.Task[object], threading.Thread]&quot; = {}
                ^
  SyntaxError: invalid syntax
  [2021-09-08 11:21:00 +0000] [29382] [INFO] Worker exiting (pid: 29382)
  [2021-09-08 11:21:00 +0000] [29379] [INFO] Shutting down: Master
  [2021-09-08 11:21:00 +0000] [29379] [INFO] Reason: Worker failed to boot.
  </code></pre>
  <p>When I run <code>gunicorn --bind 0.0.0.0:8000 logistics.wsgi:application</code>, (that is, without <code>sudo</code>) I get another error:</p>
  <pre><code>(venv) ubuntu@ip-172-31-18-196:/var/www/html$ gunicorn --bind 0.0.0.0:8000 logistics.wsgi:application
  Traceback (most recent call last):
    File &quot;/home/ubuntu/.local/bin/gunicorn&quot;, line 7, in &lt;module&gt;
      from gunicorn.app.wsgiapp import run
  ModuleNotFoundError: No module named 'gunicorn'
  </code></pre>
  <p>But I have already install gunicorn with the command <code>pip3 install gunicorn --user</code>. The reason why I added <code>--user</code> at the end is that running <code>pip3 install gunicorn</code> within the activated virtual enviroment is throwing back permission error as shown below:</p>
  <pre><code>(venv) ubuntu@ip-172-31-18-196:/var/www/html$ pip3 install gunicorn
  Collecting gunicorn
    Using cached https://files.pythonhosted.org/packages/e4/dd/5b190393e6066286773a67dfcc2f9492058e9b57c4867a95f1ba5caf0a83/gunicorn-20.1.0-py3-none-any.whl
  Requirement already satisfied: setuptools&gt;=3.0 in ./venv/lib/python3.6/site-packages (from gunicorn) (40.6.2)
  Installing collected packages: gunicorn
  Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/var/www/html/venv/lib/python3.6/site-packages/gunicorn-20.1.0.dist-info'
  Consider using the `--user` option or check the permissions.
  
  You are using pip version 18.1, however version 21.2.4 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  </code></pre>
  <p>Again, I have already upgraded from <code>python3.5</code> to <code>python3.6</code> such that when I run python3 on the terminal I get the following output</p>
  <pre><code>(venv) ubuntu@ip-172-31-18-196:/var/www/html$ python3 --version
  Python 3.6.13
  </code></pre>
  <p>Yet, I don't know why the error log is making reference to python3.5 instead of python3.6 as shown here: <code>File &quot;/usr/local/lib/python3.5/dist-packages/gunicorn/app/wsgiapp.py&quot;</code> whenever I run <code>sudo gunicorn --bind 0.0.0.0:8000 logistics.wsgi:application</code>
  Please I want to know why I'm getting that error</p>