title: ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2._psycopg' zappa
body: <p>I am using zappa to deploy backend to the AWS Lambda. It worked well, until I decided to use PostgreSQL. I added it in the settings like this:</p>
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql',
          'NAME': config('DATABASE_NAME'),
          'USER': config('DATABASE_USER'),
          'PASSWORD': config('DATABASE_PASSWORD'),
          'HOST': config('DATABASE_HOST'),
          'PORT': '5432'
      }
  }
  </code></pre>
  <p>I am using AWS RDS. I installed psycopg2-binary and also psycopg2 (versions 2.8.6), but the issue remains. The python version is 3.8.</p>
  <p>The full error log:</p>
  <pre><code>   [1621168086542] [ERROR] ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2._psycopg'
  Traceback (most recent call last):
    File &quot;/var/task/handler.py&quot;, line 609, in lambda_handler
      return LambdaHandler.lambda_handler(event, context)
    File &quot;/var/task/handler.py&quot;, line 240, in lambda_handler
      handler = cls()
    File &quot;/var/task/handler.py&quot;, line 146, in __init__
      wsgi_app_function = get_django_wsgi(self.settings.DJANGO_SETTINGS)
    File &quot;/var/task/zappa/ext/django_zappa.py&quot;, line 20, in get_django_wsgi
      return get_wsgi_application()
    File &quot;/var/task/django/core/wsgi.py&quot;, line 12, in get_wsgi_application
      django.setup(set_prefix=False)
    File &quot;/var/task/django/__init__.py&quot;, line 24, in setup
      apps.populate(settings.INSTALLED_APPS)
    File &quot;/var/task/django/apps/registry.py&quot;, line 114, in populate
      app_config.import_models()
    File &quot;/var/task/django/apps/config.py&quot;, line 211, in import_models
      self.models_module = import_module(models_module_name)
    File &quot;/var/lang/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 975, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 671, in _load_unlocked
    File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 783, in exec_module
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 219, in _call_with_frames_removed
    File &quot;/var/task/django/contrib/auth/models.py&quot;, line 2, in &lt;module&gt;
      from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
    File &quot;/var/task/django/contrib/auth/base_user.py&quot;, line 48, in &lt;module&gt;
      class AbstractBaseUser(models.Model):
    File &quot;/var/task/django/db/models/base.py&quot;, line 122, in __new__
      new_class.add_to_class('_meta', Options(meta, app_label))
    File &quot;/var/task/django/db/models/base.py&quot;, line 326, in add_to_class
      value.contribute_to_class(cls, name)
    File &quot;/var/task/django/db/models/options.py&quot;, line 206, in contribute_to_class
      self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
    File &quot;/var/task/django/db/__init__.py&quot;, line 28, in __getattr__
      return getattr(connections[DEFAULT_DB_ALIAS], item)
    File &quot;/var/task/django/db/utils.py&quot;, line 214, in __getitem__
      backend = load_backend(db['ENGINE'])
    File &quot;/var/task/django/db/utils.py&quot;, line 111, in load_backend
      return import_module('%s.base' % backend_name)
    File &quot;/var/lang/lib/python3.8/importlib/__init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;/var/task/django/db/backends/postgresql/base.py&quot;, line 29, in &lt;module&gt;
      raise ImproperlyConfigured(&quot;Error loading psycopg2 module: %s&quot; % e)
  </code></pre>