pythonpython-poetry

Build error with python-lzf while updating package with poetry


I am trying to update a package via poetry, but get an error with python-lzf which is one of the dependencies.

$ poetry update package_name

- Installing python-lzf (0.2.6): Failed
  building 'lzf' extension
  creating build/temp.linux-x86_64-cpython-310
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I. -I/tmp/tmp82n7yqdz/.venv/include -I/usr/include/python3.10 -c lzf_c.c -o build/temp.linux
-x86_64-cpython-310/lzf_c.o -Wall
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I. -I/tmp/tmp82n7yqdz/.venv/include -I/usr/include/python3.10 -c lzf_d.c -o build/temp.linux
-x86_64-cpython-310/lzf_d.o -Wall
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I. -I/tmp/tmp82n7yqdz/.venv/include -I/usr/include/python3.10 -c lzf_module.c -o build/temp.
linux-x86_64-cpython-310/lzf_module.o -Wall
  lzf_module.c:3:10: fatal error: Python.h: No such file or directory
      3 | #include "Python.h"
        |          ^~~~~~~~~~
  compilation terminated.
  error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

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

However, this works just fine.

$ pip wheel --no-cache-dir --use-pep517 "python-lzf (==0.2.6)"
Collecting python-lzf==0.2.6
Building wheels for collected packages: python-lzf
  Created wheel for python-lzf
Successfully built python-lzf

Solution

  • The Python development headers are missing. The file Python.h is part of python3-dev. It must be installed, try:

    python --version                 # say python 3.13
    sudo apt install python3.13-dev  # install the appropriate dev package