django-zappa: Error loading psycopg2 module: libpq.so.5: cannot open shared object file: No such file or directory

Question:

When trying to deploy a Django project using django-zappa, I get the following error in the zappa tail output:

django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: libpq.so.5: cannot open shared object file: No such file or directory

I’ve made sure to include the psycopg2 module in the requirements file:

psycopg2==2.8.3

It’s installed in the virtual environment that’s active while running the zappa deploy command.

I’m running on Linux and had to install libpq-dev via apt before even being able to pip install psycopg2 as I received an error before, saying that libpq was missing on the system (similar to the above error, I guess).

How can I overcome this error?

Thanks!

Asked By: OhMad

||

Answers:

I managed to solve the problem by installing the psycopg2-binary package:

pip install psycopg2-binary

After a redeploy, it works fine.

Answered By: OhMad

I encountered the same problem when runing django in a raspberrypi model 3 B+ with the latest os.

sudo  apt-get install libpq5 -y 

worked for me