I installed pyscopg3 on my venv using pip install psycopg[binary] as per the documentation but I still get an import error:
Exception has occurred: ImportError
no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'
- couldn't import psycopg 'binary' implementation: DLL load failed while importing pq: The specified module could not be found.
- couldn't import psycopg 'python' implementation: libpq library not found
I'm running a Windows 10 machine. How can I solve this error?
You need to install the command line tools on PostgreSQL on your Windows machine. Download the full server installer here: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
You don't need to install the full server package, only
command line toolsin the installer options will be necessary:After the installation, you need to add the PostgreSQL
binfolder in yourPATHenvironnement variable:hit
+R at the same time to get command prompt. Then type
sysdm.cpl, go to advanced and select "Environment Variables", in PATH add the path to :C:\Program Files\PostgreSQL\13\bin\folder (or whatever folder you choose to install the PostreSQL commande line tools).IMPORTANT: do not forget to close and restart your dev environnement (ie: VSCode, PyCharm, ...) to take the new environnement variable into account.
Note : This answer is related to Windows machine. For Linux the installation of a at least one
postgresql-client-<version>package will be enough.related to: https://stackoverflow.com/a/60369228/5341247