chatgpt-retrieval-plugin icon indicating copy to clipboard operation
chatgpt-retrieval-plugin copied to clipboard

Installing psycopg2 (2.9.6): Failed

Open JanHorcicka opened this issue 1 year ago • 5 comments

I am following the Quickstart guide. When running poetry install, all dependencies get installed, but the installation for the psycopg2 fails. This is the error message:

• Installing psycopg2 (2.9.6): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel
  
  /private/var/folders/v3/11r_zs0x2j98lm4nn7pqfbkc0000gr/T/tmpcz77uvx9/.venv/lib/python3.10/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
  !!
  
          ********************************************************************************
          The license_file parameter is deprecated, use license_files instead.
  
          By 2023-Oct-30, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.
  
          See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
          ********************************************************************************
  
  !!
    parsed = self.parsers.get(option_name, lambda x: x)(value)
  running egg_info
  writing psycopg2.egg-info/PKG-INFO
  writing dependency_links to psycopg2.egg-info/dependency_links.txt
  writing top-level names to psycopg2.egg-info/top_level.txt
  
  Error: pg_config executable not found.
  
  pg_config is required to build psycopg2 from source.  Please add the directory
  containing pg_config to the $PATH or specify the full executable path with the
  option:
  
      python setup.py build_ext --pg-config /path/to/pg_config build ...
  
  or with the pg_config option in 'setup.cfg'.
  
  If you prefer to avoid building psycopg2 from source, please install the PyPI
  'psycopg2-binary' package instead.
  
  For further information please check the 'doc/src/install.rst' file (also at
  <https://www.psycopg.org/docs/install.html>).
  
  

  at ~/Library/Python/3.9/lib/python/site-packages/poetry/installation/chef.py:152 in _prepare
      148│ 
      149│                 error = ChefBuildError("\n\n".join(message_parts))
      150│ 
      151│             if error is not None:
    → 152│                 raise error from None
      153│ 
      154│             return path
      155│ 
      156│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with psycopg2 (2.9.6) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "psycopg2 (==2.9.6)"'. 

I am not planning to use psycopg2 as a datastore, but this blocks installation of new packages (like jwt to create a bearer token). Can you please advise or fix it?

JanHorcicka avatar May 18 '23 14:05 JanHorcicka

Same issue here. Did u find a way to fix it? Just have it all time during installation

PabloSergi avatar May 22 '23 08:05 PabloSergi

Try to install pg dependencies before doing the poetry install and it should work out.

On ubuntu/debian: sudo apt install -y libpq-dev

KKastberg avatar May 22 '23 08:05 KKastberg

Same issue here. Did u find a way to fix it? Just have it all time during installation

This issue relates to OpenSSL, install OpenSSL via brew or apt, and then update the LIBRARY_PATH env to fix the issue.

brew install openssl For macOS on Apple Silicon, use: export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/opt/openssl/lib For macOS on Intel based chips: export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

verheesj avatar May 23 '23 11:05 verheesj

This is relates to pg_config file in the path. So If you're on mac, installing postgresql should fix the issue.

brew install postgresql

arch -arm64 brew install postgresql (if you're on apple silicon)

randybaek avatar May 24 '23 10:05 randybaek

Having to install Postgres on every system is quite bad... :-(

psycopg2 dependency should be optional, e.g. only for installations using Postgresql, something like

[tool.poetry.group.postgres.dependencies]
psycopg2 = "^2.9.5"

or

psycopg2 = {version = "^2.9.5", optional = true}

dluc avatar Nov 10 '23 18:11 dluc