I cannot get psycopg2-binary
package to install via poetry in python3.12.
pyproject.toml
[tool.poetry]
name = "my_project"
[tool.poetry.dependencies]
psycopg2-binary = "*"
[build-system]
requires = ["poetry-core>=1.8.1"]
build-backend = "poetry.core.masonry.api"
Installing the project in python 3.11 works. psycopg2-binary
installs.
When I try to install with poetry in a python 3.12 environment, the following error occurs:
poetry install --with dev --sync
Installing dependencies from lock file
Package operations: 1 install, 0 updates, 0 removals
• Installing psycopg2-binary (2.9.9): Failed
ChefBuildError
Backend subprocess exited when trying to invoke get_requires_for_build_wheel
running egg_info
writing psycopg2_binary.egg-info/PKG-INFO
writing dependency_links to psycopg2_binary.egg-info/dependency_links.txt
writing top-level names to psycopg2_binary.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 ~/.pyenv/versions/3.12.0/envs/poetry312/lib/python3.12/site-packages/poetry/installation/chef.py:166 in _prepare
162│
163│ error = ChefBuildError("\n\n".join(message_parts))
164│
165│ if error is not None:
→ 166│ raise error from None
167│
168│ return path
169│
170│ 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-binary (2.9.9) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "psycopg2-binary (==2.9.9)"'.
What confuses me is the error looks like it's attempting to install pyscopg2
not psycopg2-binary
.
I don't fully understand the note at the bottom.
Note: This error originates from the build backend, and is likely not a problem with poetry but with psycopg2-binary (2.9.9) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "psycopg2-binary (==2.9.9)"'.
When I execute pip wheel --no-cache-dir --use-pep517 "psycopg2-binary (==2.9.9)"
the following returns:
$ pip wheel --no-cache-dir --use-pep517 "psycopg2-binary (==2.9.9)"
Collecting psycopg2-binary==2.9.9
Downloading psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl.metadata (4.4 kB)
Downloading psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl (2.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.6/2.6 MB 2.4 MB/s eta 0:00:00
Saved ./psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl
I don't understand what this verified....
In addition, I'm able to install psycopg2-binary
via pip just fine.
- MacOS 14 (sonoma) M2
- Poetry 1.7.0