psycopg / psycopg2

PostgreSQL database adapter for the Python programming language
https://www.psycopg.org/
Other
3.35k stars 506 forks source link

Anyone experiences psycopg2-2.9.10 installation failure with python3.8 on Windows? #1741

Open amethystzh opened 3 days ago

amethystzh commented 3 days ago

Discussed in https://github.com/psycopg/psycopg2/discussions/1740

Originally posted by **amethystzh** October 22, 2024 Hi, here I have a problem, that when I tried to install the latest 2.9.10 on my Windows with python3.8, it failed. yet when I tried with python3.11 it succeed. I tried with 2 of my windows PC both the same way. one is Python3.8.5, the other is Python3.8.8. I also tried on my Linux with Python3.8 it can succeed, summarize as below: |OS |Python|result| ----|--------|-----| |Win|3.8.5|failed| |Win|3.8.8|failed| |Win|3.11.8|succeed| |Linux|3.8.5|succeed| seems 2.9.10 release note clarify it adds supporting for 3.13 & drops supporting for 3.7, yet has not mention 3.8, so I think it will still support 3.8? there's an issue raised for psycopg2-binary for 3.9, but from the comments seems it's only for binary on Mac? https://github.com/psycopg/psycopg2/issues/1737
EngineerHus commented 2 days ago

same issue here when trying to pip install psycopg2 for python3.8. The error I see is this:

Collecting psycopg2
  Downloading psycopg2-2.9.10.tar.gz (385 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      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>).

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
PauloMalet commented 1 day ago

Similar issue for me on Ubuntu 24.04 for python 3.10 (and install works on python 3.12) when running uv pip install psycopg2 :

Resolved 1 package in 2ms
error: Failed to prepare distributions
  Caused by: Failed to download and build `psycopg2==2.9.10`
  Caused by: Build backend failed to build wheel through `build_wheel` (exit status: 1)

[stdout]
running bdist_wheel
running build
running build_py
copying lib/extras.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-cpython-310/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-cpython-310/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
clang -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC "-DPSYCOPG_VERSION=2.9.10 (dt dec pq3 ext lo64)" -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=160004 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/paul/.cache/uv/builds-v0/.tmphdlEai/include -I/home/paul/.local/share/uv/python/cpython-3.10.13-linux-x86_64-gnu/include/python3.10 -I. -I/usr/include/postgresql -I/usr/include/postgresql/16/server -I/usr/include/libxml2 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-cpython-310/psycopg/adapter_asis.o -Wdeclaration-after-statement

[stderr]

It appears you are missing some prerequisite to build the package from source.

You may install a binary package by installing 'psycopg2-binary' from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.

For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).

error: command 'clang' failed: No such file or directory
spirillen commented 7 hours ago

Not for windows,but on FreeBSD 14.1 when trying to install PyFunceble

Collecting psycopg2-binary (from SQLAlchemy[postgresql_psycopg2binary]~=2.0->pyfunceble-dev)
  Downloading psycopg2-binary-2.9.10.tar.gz (385 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 385.8/385.8 kB 517.9 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      running egg_info
      creating /tmp/pip-pip-egg-info-0xivj2jr/psycopg2_binary.egg-info
      writing /tmp/pip-pip-egg-info-0xivj2jr/psycopg2_binary.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-pip-egg-info-0xivj2jr/psycopg2_binary.egg-info/dependency_links.txt
      writing top-level names to /tmp/pip-pip-egg-info-0xivj2jr/psycopg2_binary.egg-info/top_level.txt
      writing manifest file '/tmp/pip-pip-egg-info-0xivj2jr/psycopg2_binary.egg-info/SOURCES.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>).

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.