jazzband / django-redshift-backend

Redshift database backend for Django
Apache License 2.0
83 stars 48 forks source link

#149 Added a clear message on ImportError when the psycopg2 package cannot be found. #159

Closed shimizukawa closed 3 weeks ago

shimizukawa commented 1 month ago

Details #150.

As there is no valid way to explicitly depend on psycopg2 at this time, the error message has been made easier to understand.

(venv) @shimizukawa ➜ /tmp/proj $ python
Python 3.8.19 (default, Aug 14 2024, 05:07:38) 
[Clang 18.1.8 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django_redshift_backend.base
Traceback (most recent call last):
  File "/tmp/proj/venv/lib/python3.8/site-packages/django_redshift_backend/base.py", line 24, in <module>
    from psycopg2.extensions import Binary
ModuleNotFoundError: No module named 'psycopg2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/proj/venv/lib/python3.8/site-packages/django_redshift_backend/base.py", line 26, in <module>
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module. Please install as: `pip install django-redshift-backend[psycopg2]` or `pip install django-redshift-backend[psycopg2-binary]`. For more information, see https://django-redshift-backend.readthedocs.io/en/master/basic.html#installation

Error loading psycopg2 module. Please install as:pip install django-redshift-backend[psycopg2]orpip install django-redshift-backend[psycopg2-binary]. For more information, see https://django-redshift-backend.readthedocs.io/en/master/basic.html#installation