PacktPublishing / Django-4-by-example

Django 4 by example (4th Edition) published by Packt
https://djangobyexample.com/
MIT License
818 stars 461 forks source link

Chapter 3: Migrating to PostgreSql psycopg2 module not found #27

Closed DavidLima17 closed 1 year ago

DavidLima17 commented 1 year ago

Hi there, wanting to get some help with this issue.

I am trying to migrate to postgres but am encountering this exception when I migrate

File "D:\Documents\workspaces\vscode_workspace\projects\my_env\Lib\site-packages\django\db\backends\postgresql\base.py", line 28, in <module> raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: DLL load failed while importing _psycopg: The specified module could not be found.

i looked at some of the previous issues and tried to see if their solutions could help me.

this is in my settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'blog', 'USER': 'blog', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': 5432 } }

I have also tried running "pip install postgres" to try and see if there was something else i was missing but no success there either.

mohammed-manahi commented 1 year ago

@DavidLima17 Try django.db.backends.postgresql_psycopg2 for the database engine.

auvipy commented 1 year ago

you should try pip install psycopg2-binary/ psycopg2

auvipy commented 1 year ago

@DavidLima17 Try django.db.backends.postgresql_psycopg2 for the database engine.

you are suggesting a deprecated settings.

DavidLima17 commented 1 year ago

you should try pip install psycopg2-binary/ psycopg2

Thank you! running 'pip install psycopg2' seemed to satisfy what i was missing and it migrated.