No `psycopg` 3 (PostgreSQL Python library) support?

Setup: Django, Python

A discussion from 2022 suggests a workaround which worked for me, basically to pin to an older version psycopg2 binary.

However, it’s 2025 and I’d like to use the more modern psycopg3 with Django. I’m currently evaluating vercel vs Railway, and have this in my requirements.txt file:

psycopg==3.2.4

Building this fails on vercel. I tried doing this at the beginning of my buildfiles.sh script:

echo "Step 7: Installing Python dependencies"
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade setuptools
python3 -m pip install -r requirements.txt
python3 -m pip uninstall -y psycopg
python3 -m pip install "psycopg[binary]"

But it still fails with this appearing in the logs:

No module named 'psycopg_c'
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: libpq library not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/task/django/db/backends/postgresql/base.py", line 27, in <module>
import psycopg2 as Database
ModuleNotFoundError: No module named 'psycopg2'

The only thing that works for me is specifying this in requirements.txt:

psycopg2-binary~=2.9.3

But:

  1. I don’t want to use the older psycopg 2
  2. I want to evaluate my app on two providers, and changing requirements.txt will “downgrade” psycopg on both.

Is there any channel where I can get in touch with support?

Hi @shxkm, welcome to the Vercel Community!

Sorry that you are facing this issue. I’ve reached out to our team to see how this can be solved.

Thank you. Awaiting your reply as I’m currently weighing a few different hosts for an upcoming project.

1 Like

Hi @shxkm, thanks for waiting. The team is internally discussing how this can be done. But, as of today this is not supported. Also, we don’t have a timeline for the solution because this issue is more than the runtime.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.