Reputation: 511
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?
Upvotes: 51
Views: 41787
Reputation: 51
I had a similar problem with import psycopg
ImportError: no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: No module named 'psycopg_c'
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: function 'PQsslInUse' not found
Updating the version postgresql helped me (from 9.4 to 10.12.1). In Postgreql 9.4 libpq.dll doesn't have exported function PQsslInUse, but libpq in Postgresql 10.12.1 have. To run utils that use psycopg i use alias in git-bash
alias pgcli='PATH=/d/Portable/postgresql-10.12.1-windows-binaries/pgsql/bin/:$PATH pgcli'
Upvotes: 1
Reputation: 801
I followed the psycopg installation steps from https://pypi.org/project/psycopg/
pip install --upgrade pip # to upgrade pip
pip install "psycopg[binary,pool]" # to install package and dependencies
it worked for me
Upvotes: 70
Reputation: 670
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 tools
in the installer options will be necessary:
After the installation, you need to add the PostgreSQL bin
folder in your PATH
environnement 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
Upvotes: 17