I’m deploying a Django project in a cPanel hosting environment (NameCheap).
NameCheap currently only supports PostgreSQL: 8.4.20.
I want to use PostgreSQL as my Django database backend but (see bold requirement):
The current psycopg2 implementation supports:
- Python version 2.7
- Python 3 versions from 3.4 to 3.8
- PostgreSQL server versions from 7.4 to 12
- PostgreSQL client library version from 9.1
Upgrading from 8.4.20 to >= 9.1 is not an option in NameCheap (shared hosting plan).
So my problem is, if I attempt to do a pip install psycopg2
, I receive an error:
./psycopg/psycopg.h:30:2: error: #error "Psycopg requires
PostgreSQL client library (libpq) >= 9.1
BECAUSE PostgreSQL 8.4.20 < PostgreSQL: 9.1.
My Question Is:
Is psycopg2 the only “approved”(?) / “official” / “supported” module for Django and PostgreSQL? If not, what psycopg2 alternative package could I use and how to implement in general?
2
Answers
You can install psycopg 2.6.2. Libpq >= 9.1 is required only since psycopg 2.7.
Try
pip install "psycopg2<2.7"
.I also tried to use PostgreSQL database with Django on Namecheap shared hosting. I faced problems in the beginning but now I am using it without a problem. Here is the procedure you can follow to use PostgreSQL database with Django on shared hosting (Although I am using psycopg2):
Make sure to use 127.0.0.1 instead of localhost
I am using Python 3.7 and Django 3.0
I have also written a post about this on my blog.