Failed building wheel for psycopg-c (v4.0) #9630

Closed
opened 2025-12-29 21:20:02 +01:00 by adam · 5 comments
Owner

Originally created by @wz4 on GitHub (May 8, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.0.0

Python Version

3.12

Steps to Reproduce

OS: Ubuntu 22.04
Python: 3.12.3

Attempting to run upgrade script fails.
PYTHON=/usr/bin/python3.12 ./upgrade.sh

Expected Behavior

Upgrade script should rebuild virtual environment and install dependencies.

Observed Behavior

Building wheels for collected packages: django-pglocks, psycopg-c, paginate, sgmllib3k, promise
  Building wheel for django-pglocks (pyproject.toml) ... done
  Created wheel for django-pglocks: filename=django_pglocks-1.0.4-py3-none-any.whl size=3856 sha256=81b5cd8ce3989b89d299cb870bd48696b54d5fb595e5813a40a63adcd3269b60
  Stored in directory: /root/.cache/pip/wheels/0d/1f/d0/246defef038eee0be5c9e7f6e19cd85d10fbc3133bb43ad200
  Building wheel for psycopg-c (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for psycopg-c (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-312
      creating build/lib.linux-x86_64-cpython-312/psycopg_c
      copying psycopg_c/version.py -> build/lib.linux-x86_64-cpython-312/psycopg_c
      copying psycopg_c/__init__.py -> build/lib.linux-x86_64-cpython-312/psycopg_c
      copying psycopg_c/_psycopg.pyi -> build/lib.linux-x86_64-cpython-312/psycopg_c
      copying psycopg_c/py.typed -> build/lib.linux-x86_64-cpython-312/psycopg_c
      copying psycopg_c/pq.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c
      creating build/lib.linux-x86_64-cpython-312/psycopg_c/_psycopg
      copying psycopg_c/_psycopg/endian.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/_psycopg
      copying psycopg_c/_psycopg/__init__.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/_psycopg
      copying psycopg_c/_psycopg/oids.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/_psycopg
      creating build/lib.linux-x86_64-cpython-312/psycopg_c/pq
      copying psycopg_c/pq/libpq.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/pq
      copying psycopg_c/pq/__init__.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/pq
      running build_ext
      building 'psycopg_c._psycopg' extension
      creating build/temp.linux-x86_64-cpython-312
      creating build/temp.linux-x86_64-cpython-312/psycopg_c
      creating build/temp.linux-x86_64-cpython-312/psycopg_c/types
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/postgresql -I/opt/netbox/venv/include -I/usr/include/python3.12 -c psycopg_c/_psycopg.c -o build/temp.linux-x86_64-cpython-312/psycopg_c/_psycopg.o
      psycopg_c/_psycopg.c:42:10: fatal error: Python.h: No such file or directory
         42 | #include "Python.h"
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for psycopg-c
  Building wheel for paginate (pyproject.toml) ... done
  Created wheel for paginate: filename=paginate-0.5.6-py3-none-any.whl size=12667 sha256=6e8f6aeebeafe0864dd609e18c8c750827a704501c9f455d54956680ba8bfff1
  Stored in directory: /root/.cache/pip/wheels/03/20/4e/4925d1027f4b377bef23999a1a5eaa438339b741a6a2f3ad39
  Building wheel for sgmllib3k (pyproject.toml) ... done
  Created wheel for sgmllib3k: filename=sgmllib3k-1.0.0-py3-none-any.whl size=6049 sha256=b3f09987f3193c876b3d7b16ea6fe5e3f1d77ff1cbca176f89c9c4ca4bf71b96
  Stored in directory: /root/.cache/pip/wheels/03/f5/1a/23761066dac1d0e8e683e5fdb27e12de53209d05a4a37e6246
  Building wheel for promise (pyproject.toml) ... done
  Created wheel for promise: filename=promise-2.3-py3-none-any.whl size=21483 sha256=3e62abc3d8c8d4422817e48ce07de856eb470fad3674a4c846ad17d6049843a1
  Stored in directory: /root/.cache/pip/wheels/e7/e6/28/864bdfee5339dbd6ddcb5a186286a8e217648ec198bdf0097d
Successfully built django-pglocks paginate sgmllib3k promise
Failed to build psycopg-c
ERROR: Could not build wheels for psycopg-c, which is required to install pyproject.toml-based projects
Originally created by @wz4 on GitHub (May 8, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.0.0 ### Python Version 3.12 ### Steps to Reproduce OS: Ubuntu 22.04 Python: 3.12.3 Attempting to run upgrade script fails. PYTHON=/usr/bin/python3.12 ./upgrade.sh ### Expected Behavior Upgrade script should rebuild virtual environment and install dependencies. ### Observed Behavior ``` Building wheels for collected packages: django-pglocks, psycopg-c, paginate, sgmllib3k, promise Building wheel for django-pglocks (pyproject.toml) ... done Created wheel for django-pglocks: filename=django_pglocks-1.0.4-py3-none-any.whl size=3856 sha256=81b5cd8ce3989b89d299cb870bd48696b54d5fb595e5813a40a63adcd3269b60 Stored in directory: /root/.cache/pip/wheels/0d/1f/d0/246defef038eee0be5c9e7f6e19cd85d10fbc3133bb43ad200 Building wheel for psycopg-c (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for psycopg-c (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [29 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-cpython-312 creating build/lib.linux-x86_64-cpython-312/psycopg_c copying psycopg_c/version.py -> build/lib.linux-x86_64-cpython-312/psycopg_c copying psycopg_c/__init__.py -> build/lib.linux-x86_64-cpython-312/psycopg_c copying psycopg_c/_psycopg.pyi -> build/lib.linux-x86_64-cpython-312/psycopg_c copying psycopg_c/py.typed -> build/lib.linux-x86_64-cpython-312/psycopg_c copying psycopg_c/pq.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c creating build/lib.linux-x86_64-cpython-312/psycopg_c/_psycopg copying psycopg_c/_psycopg/endian.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/_psycopg copying psycopg_c/_psycopg/__init__.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/_psycopg copying psycopg_c/_psycopg/oids.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/_psycopg creating build/lib.linux-x86_64-cpython-312/psycopg_c/pq copying psycopg_c/pq/libpq.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/pq copying psycopg_c/pq/__init__.pxd -> build/lib.linux-x86_64-cpython-312/psycopg_c/pq running build_ext building 'psycopg_c._psycopg' extension creating build/temp.linux-x86_64-cpython-312 creating build/temp.linux-x86_64-cpython-312/psycopg_c creating build/temp.linux-x86_64-cpython-312/psycopg_c/types x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/postgresql -I/opt/netbox/venv/include -I/usr/include/python3.12 -c psycopg_c/_psycopg.c -o build/temp.linux-x86_64-cpython-312/psycopg_c/_psycopg.o psycopg_c/_psycopg.c:42:10: fatal error: Python.h: No such file or directory 42 | #include "Python.h" | ^~~~~~~~~~ compilation terminated. error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for psycopg-c Building wheel for paginate (pyproject.toml) ... done Created wheel for paginate: filename=paginate-0.5.6-py3-none-any.whl size=12667 sha256=6e8f6aeebeafe0864dd609e18c8c750827a704501c9f455d54956680ba8bfff1 Stored in directory: /root/.cache/pip/wheels/03/20/4e/4925d1027f4b377bef23999a1a5eaa438339b741a6a2f3ad39 Building wheel for sgmllib3k (pyproject.toml) ... done Created wheel for sgmllib3k: filename=sgmllib3k-1.0.0-py3-none-any.whl size=6049 sha256=b3f09987f3193c876b3d7b16ea6fe5e3f1d77ff1cbca176f89c9c4ca4bf71b96 Stored in directory: /root/.cache/pip/wheels/03/f5/1a/23761066dac1d0e8e683e5fdb27e12de53209d05a4a37e6246 Building wheel for promise (pyproject.toml) ... done Created wheel for promise: filename=promise-2.3-py3-none-any.whl size=21483 sha256=3e62abc3d8c8d4422817e48ce07de856eb470fad3674a4c846ad17d6049843a1 Stored in directory: /root/.cache/pip/wheels/e7/e6/28/864bdfee5339dbd6ddcb5a186286a8e217648ec198bdf0097d Successfully built django-pglocks paginate sgmllib3k promise Failed to build psycopg-c ERROR: Could not build wheels for psycopg-c, which is required to install pyproject.toml-based projects ```
adam closed this issue 2025-12-29 21:20:03 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 8, 2024):

It looks like you're missing the development libraries for Python 3.12. Try running

sudo apt install python3.12-dev

and then re-running the upgrade script.

@jeremystretch commented on GitHub (May 8, 2024): It looks like you're missing the development libraries for Python 3.12. Try running ``` sudo apt install python3.12-dev ``` and then re-running the upgrade script.
Author
Owner

@wz4 commented on GitHub (May 8, 2024):

I'm encountering the same error with python3.10 and 3.12. I do have the dev library installed.

apt list --installed | grep python3.1

idle-python3.10/jammy-updates,jammy-updates,jammy-security,jammy-security,now 3.10.12-1~22.04.3 all [installed,automatic]
libpython3.10-dev/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
libpython3.10-minimal/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
libpython3.10-stdlib/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
libpython3.10/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
libpython3.12-dev/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic]
libpython3.12-minimal/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic]
libpython3.12-stdlib/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic]
libpython3.12/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic]
python3.10-dev/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
python3.10-minimal/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
python3.10-venv/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
python3.10/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic]
python3.12-dev/jammy,now 3.12.3-1+jammy1 amd64 [installed]
python3.12-lib2to3/jammy,jammy,now 3.12.3-1+jammy1 all [installed,auto-removable]
python3.12-minimal/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic]
python3.12-venv/jammy,now 3.12.3-1+jammy1 amd64 [installed]
python3.12/jammy,now 3.12.3-1+jammy1 amd64 [installed]
@wz4 commented on GitHub (May 8, 2024): I'm encountering the same error with python3.10 and 3.12. I do have the dev library installed. ``` apt list --installed | grep python3.1 idle-python3.10/jammy-updates,jammy-updates,jammy-security,jammy-security,now 3.10.12-1~22.04.3 all [installed,automatic] libpython3.10-dev/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic] libpython3.10-minimal/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic] libpython3.10-stdlib/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic] libpython3.10/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic] libpython3.12-dev/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic] libpython3.12-minimal/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic] libpython3.12-stdlib/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic] libpython3.12/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic] python3.10-dev/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic] python3.10-minimal/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic] python3.10-venv/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic] python3.10/jammy-updates,jammy-security,now 3.10.12-1~22.04.3 amd64 [installed,automatic] python3.12-dev/jammy,now 3.12.3-1+jammy1 amd64 [installed] python3.12-lib2to3/jammy,jammy,now 3.12.3-1+jammy1 all [installed,auto-removable] python3.12-minimal/jammy,now 3.12.3-1+jammy1 amd64 [installed,automatic] python3.12-venv/jammy,now 3.12.3-1+jammy1 amd64 [installed] python3.12/jammy,now 3.12.3-1+jammy1 amd64 [installed] ```
Author
Owner

@wz4 commented on GitHub (May 8, 2024):

Installing libpq-dev fixed the problem.

@wz4 commented on GitHub (May 8, 2024): Installing libpq-dev fixed the problem.
Author
Owner

@lundgrenolof commented on GitHub (May 13, 2024):

It looks like you're missing the development libraries for Python 3.12. Try running

sudo apt install python3.12-dev

and then re-running the upgrade script.

Is python3.12 a requirement now? Ubuntu 22.04 doesnt seem to have python3.12 in repo.
python3.11rc is available, but also fails.

Edit: I installed python3-psycopg2 from apt repo. Now it will upgrade from 3.7.5 to 4.0.1

Maybe psycopg2 should be added from pip repo instead using requirements.txt? Edit, that didnt help. Only python3-psycopg2 from apt repo seemed to help.

@jeremystretch reopen issue?

(venv) olof@netbox:/opt/netbox$ grep psycop requirements.txt 
psycopg[c,pool]==3.1.18


(venv) olof@netbox:/opt/netbox$ pip install psycopg2==1337
ERROR: Could not find a version that satisfies the requirement psycopg2==1337 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1, 2.9.2, 2.9.3, 2.9.4, 2.9.5, 2.9.6, 2.9.7, 2.9.8, 2.9.9)
ERROR: No matching distribution found for psycopg2==1337

(venv) olof@netbox:/opt/netbox$ dpkg -l | grep psycopg2
ii  python3-psycopg2                 2.9.2-1build2                           amd64        Python 3 module for PostgreSQL
@lundgrenolof commented on GitHub (May 13, 2024): > It looks like you're missing the development libraries for Python 3.12. Try running > > ``` > sudo apt install python3.12-dev > ``` > > and then re-running the upgrade script. Is python3.12 a requirement now? Ubuntu 22.04 doesnt seem to have `python3.12` in repo. python3.11rc is available, but also fails. Edit: I installed `python3-psycopg2` from apt repo. Now it will upgrade from 3.7.5 to 4.0.1 Maybe `psycopg2` should be added from pip repo instead using `requirements.txt`? Edit, that didnt help. Only python3-psycopg2 from apt repo seemed to help. @jeremystretch reopen issue? ``` (venv) olof@netbox:/opt/netbox$ grep psycop requirements.txt psycopg[c,pool]==3.1.18 (venv) olof@netbox:/opt/netbox$ pip install psycopg2==1337 ERROR: Could not find a version that satisfies the requirement psycopg2==1337 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1, 2.9.2, 2.9.3, 2.9.4, 2.9.5, 2.9.6, 2.9.7, 2.9.8, 2.9.9) ERROR: No matching distribution found for psycopg2==1337 (venv) olof@netbox:/opt/netbox$ dpkg -l | grep psycopg2 ii python3-psycopg2 2.9.2-1build2 amd64 Python 3 module for PostgreSQL ```
Author
Owner

@wz4 commented on GitHub (May 14, 2024):

3.10 or greater is a requirement. I installed 3.12 from deadsnakes repo.

@wz4 commented on GitHub (May 14, 2024): 3.10 or greater is a requirement. I installed 3.12 from deadsnakes repo.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9630