pgcli not working in windows 11. How to install it properly?

247 Views Asked by At

Problem -

I used pip install pgcli on my command prompt. And then used pgcli --version It is giving me this error -

C:\Users\Adarsh>pgcli --version

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Adarsh\anaconda3\Scripts\pgcli.exe\__main__.py", line 4, in <module>
  File "C:\Users\Adarsh\anaconda3\Lib\site-packages\pgcli\main.py", line 2, in <module>
    from pgspecial.namedqueries import NamedQueries
  File "C:\Users\Adarsh\anaconda3\Lib\site-packages\pgspecial\__init__.py", line 12, in <module>
    from . import dbcommands
  File "C:\Users\Adarsh\anaconda3\Lib\site-packages\pgspecial\dbcommands.py", line 7, in <module>
    from psycopg.sql import SQL
  File "C:\Users\Adarsh\anaconda3\Lib\site-packages\psycopg\__init__.py", line 9, in <module>
    from . import pq  # noqa: F401 import early to stabilize side effects
    ^^^^^^^^^^^^^^^^
  File "C:\Users\Adarsh\anaconda3\Lib\site-packages\psycopg\pq\__init__.py", line 114, in <module>
    import_from_libpq()
  File "C:\Users\Adarsh\anaconda3\Lib\site-packages\psycopg\pq\__init__.py", line 106, in import_from_libpq
    raise ImportError(
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: libpq library not found

What I tried -

  • I tried pip install psycopg2, still same error after using pgcli --version
  • I also tried doing everything in the new environment conda create --name pgcli_env python=3.8 but still same error.

My pc -

  • Windows 11
  • Python 3.11.4
  • PostgreSQL 16 App Installed

Question -

  • How to use pgcli on windows?
2

There are 2 best solutions below

0
On

This worked for me. Find the path where postgresql is installed on pc. So something like C:\ postgresql\15\bin. Locate the bin folder then copy the path and add it into system environment variable - add it in path (system env variable). After the sys env variable is added i uninstalled pgcli - pip uninstall pgcli and then opened a new terminal and reinstalled it. Works fine

0
On

Install this and it'll work fine

pip install psycopg_binary

I recently faced the same issue and this fixed the issue immediately.

See here for a description of the package.