Bruno Santos
Bruno Santos

Reputation: 1

Issue with CFFI while installing Python-MIP package

I'm trying to install mip (Python-MIP package for mathematical optimization). But, I'm facing a issue with cffi package. Bellow, the result of command pip install mip :

pip install mip
Collecting mip
  Using cached mip-1.14.2-py3-none-any.whl.metadata (21 kB)
Collecting cffi==1.15.0 (from mip)
  Using cached cffi-1.15.0.tar.gz (484 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: pycparser in ./.venv/lib/python3.12/site-packages (from cffi==1.15.0->mip) (2.22)
Using cached mip-1.14.2-py3-none-any.whl (15.3 MB)
Building wheels for collected packages: cffi
  Building wheel for cffi (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for cffi (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/__init__.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/api.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/commontypes.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/cparser.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/error.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/ffiplatform.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/lock.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/model.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/pkgconfig.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/recompiler.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/vengine_gen.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/verifier.py -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/_cffi_include.h -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/parse_c_type.h -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/_embedding.h -> build/lib.linux-x86_64-cpython-312/cffi
      copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-cpython-312/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.linux-x86_64-cpython-312/c
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/home/santos/Documentos/mathprog/.venv/include -I/usr/include/python3.12 -c c/_cffi_backend.c -o build/temp.linux-x86_64-cpython-312/c/_cffi_backend.o
      c/_cffi_backend.c:2:10: fatal error: Python.h: Arquivo ou diretório inexistente
          2 | #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 cffi
Failed to build cffi
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (cffi)

What happens whit cffi? Using Debian 12 GNU/Linux at x86_64 processor archtecture.

The only attempt to fix it was to check the mip package documentation to see if there was still a dependency that I wasn't aware of. But there isn't.

Upvotes: 0

Views: 175

Answers (1)

sascha
sascha

Reputation: 33532

The error relatively clearly states that Python (development-)headers are missing: debian -> python3-dev

Install them according to your distribution

Upvotes: 0

Related Questions