OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.91k stars 2.55k forks source link

extensions/gdal_xxxx.cpp: # include <Python.h>: fatal error: Python.h: No such file or directory #10877

Closed swiss-knight closed 1 month ago

swiss-knight commented 1 month ago

What is the bug?

Hello,

I'm in a quite specific case.

I'm trying to install the gdal Python package inside the Python (Python 3.11.7 (main, Jun 11 2024, 12:31:01) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] ) which is bundled within Blender 4.2.2 (which I downloaded and unpacked from: https://www.blender.org/download/release/Blender4.2/blender-4.2.2-linux-x64.tar.xz/ )

OS: Ubuntu 22.04.5 LTS Native Python: Python 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] on linux

apt-cache policy python3
python3:
  Installed: 3.10.6-1~22.04.1
  Candidate: 3.10.6-1~22.04.1
  Version table:
 *** 3.10.6-1~22.04.1 500
        500 http://ch.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     3.10.6-1~22.04 500
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
     3.10.4-0ubuntu2 500
        500 http://ch.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

GDAL version on my OS is 3.4.1:

$ gdalinfo --version
GDAL 3.4.1, released 2021/12/27

And the dev package is installed:

$ apt-cache policy libgdal-dev
libgdal-dev:
  Installed: 3.4.1+dfsg-1build4
  Candidate: 3.4.1+dfsg-1build4
  Version table:
 *** 3.4.1+dfsg-1build4 500
        500 http://ch.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status

But I'm facing this error when trying to pip install GDAL, naturally targeting the same version as the OS GDAL library:

~/Downloads/blender-4.2.2-linux-x64/4.2/python/bin$ ./pip3 install gdal==3.4.1
Collecting gdal==3.4.1
  Using cached GDAL-3.4.1.tar.gz (755 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: gdal
  Building wheel for gdal (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [148 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-311/osgeo
      copying osgeo/gdalconst.py -> build/lib.linux-x86_64-cpython-311/osgeo
      copying osgeo/gdal_array.py -> build/lib.linux-x86_64-cpython-311/osgeo
      copying osgeo/gnm.py -> build/lib.linux-x86_64-cpython-311/osgeo
      copying osgeo/gdal.py -> build/lib.linux-x86_64-cpython-311/osgeo
      copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-cpython-311/osgeo
      copying osgeo/ogr.py -> build/lib.linux-x86_64-cpython-311/osgeo
      copying osgeo/osr.py -> build/lib.linux-x86_64-cpython-311/osgeo
      copying osgeo/__init__.py -> build/lib.linux-x86_64-cpython-311/osgeo
      copying osgeo/utils.py -> build/lib.linux-x86_64-cpython-311/osgeo
      creating build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdalcompare.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal_proximity.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/rgb2pct.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal_calc.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal_edit.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/pct2rgb.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal_pansharpen.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/ogrmerge.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdalmove.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal2xyz.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal_polygonize.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdalattachpct.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal_merge.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal2tiles.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal_fillnodata.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal_sieve.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/gdal_retile.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      copying gdal-utils/osgeo_utils/__init__.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils
      creating build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_auth.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/crs2crs2grid.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/tigerpoly.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_rmdir.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdalcopyproj.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/vec_tr_spat.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/validate_jp2.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_lut.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/dump_jp2.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/ogrinfo.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_ls.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gcps2ogr.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/ogr_layer_algebra.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/val_repl.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/ogr2vrt.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_cp.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/build_jp2_from_xml.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/validate_gpkg.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/wcs_virtds_params.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/hsv_merge.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_vrtmerge.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/load2odbc.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/magphase.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gcps2vec.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/make_fuzzer_friendly_archive.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/jpeg_in_tiff_extract.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/tile_extent_from_raster.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_remove_towgs84.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/rel.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/histrep.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal2grd.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/ogr_build_junction_table.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/fft.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdalinfo.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/ogr2ogr.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/fix_gpkg.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdallocationinfo.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/ogrupdate.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/assemblepoly.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/tolatlong.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_mkdir.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/get_soundg.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/epsg_tr.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/ogr_dispatch.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/densify.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdalchksum.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/validate_cloud_optimized_geotiff.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdalident.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/classify.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/vec_tr.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/__init__.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/esri2wkt.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_rm.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_create_pdf.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdal_zip.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gcps2wld.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdalfilter.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/loslas2ntv2.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/gdalimport.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      copying gdal-utils/osgeo_utils/samples/mkgraticule.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/samples
      creating build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/base.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/extent_util.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/gdal_argparse.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/rectangle.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/progress.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/batch_creator.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/util.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/array_util.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/osr_util.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/color_palette.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/numpy_util.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/raster_creation.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/color_table.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      copying gdal-utils/osgeo_utils/auxiliary/__init__.py -> build/lib.linux-x86_64-cpython-311/osgeo_utils/auxiliary
      running build_ext
      g++ -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/include/python3.11 -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/lib/python3.11/site-packages/numpy/core/include -I/usr/include -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o
      building 'osgeo._gdal' extension
      creating build/temp.linux-x86_64-cpython-311/extensions
      building 'osgeo._gdalconst' extension
      building 'osgeo._osr' extension
      g++ -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/include/python3.11 -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/lib/python3.11/site-packages/numpy/core/include -I/usr/include -c extensions/osr_wrap.cpp -o build/temp.linux-x86_64-cpython-311/extensions/osr_wrap.o -I/usr/include/gdal
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/include/python3.11 -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/lib/python3.11/site-packages/numpy/core/include -I/usr/include -c extensions/gdalconst_wrap.c -o build/temp.linux-x86_64-cpython-311/extensions/gdalconst_wrap.o -I/usr/include/gdal
      building 'osgeo._ogr' extension
      g++ -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/include/python3.11 -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/lib/python3.11/site-packages/numpy/core/include -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-cpython-311/extensions/gdal_wrap.o -I/usr/include/gdal
      g++ -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/include/python3.11 -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/lib/python3.11/site-packages/numpy/core/include -I/usr/include -c extensions/ogr_wrap.cpp -o build/temp.linux-x86_64-cpython-311/extensions/ogr_wrap.o -I/usr/include/gdal
      building 'osgeo._gnm' extension
      g++ -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/include/python3.11 -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/lib/python3.11/site-packages/numpy/core/include -I/usr/include -c extensions/gnm_wrap.cpp -o build/temp.linux-x86_64-cpython-311/extensions/gnm_wrap.o -I/usr/include/gdal
      building 'osgeo._gdal_array' extension
      g++ -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/include/python3.11 -I/home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/lib/python3.11/site-packages/numpy/core/include -I/usr/include -c extensions/gdal_array_wrap.cpp -o build/temp.linux-x86_64-cpython-311/extensions/gdal_array_wrap.o -I/usr/include/gdal
      extensions/gdalconst_wrap.c:151:11: fatal error: Python.h: No such file or directory
        151 | # include <Python.h>
            |           ^~~~~~~~~~
      compilation terminated.
      extensions/ogr_wrap.cpp:175:11: fatal error: Python.h: No such file or directory
        175 | # include <Python.h>
            |           ^~~~~~~~~~
      compilation terminated.
      extensions/osr_wrap.cpp:175:11: fatal error: Python.h: No such file or directory
        175 | # include <Python.h>
            |           ^~~~~~~~~~
      compilation terminated.
      extensions/gnm_wrap.cpp:175:11: fatal error: Python.h: No such file or directory
        175 | # include <Python.h>
            |           ^~~~~~~~~~
      compilation terminated.
      extensions/gdal_array_wrap.cpp:174:11: fatal error: Python.h: No such file or directory
        174 | # include <Python.h>
            |           ^~~~~~~~~~
      compilation terminated.
      extensions/gdal_wrap.cpp:175:11: fatal error: Python.h: No such file or directory
        175 | # include <Python.h>
            |           ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/g++' 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 gdal
  Running setup.py clean for gdal
Failed to build gdal
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (gdal)

prior to that, I did:

~/Downloads/blender-4.2.2-linux-x64/4.2/python/bin$ ./python3.11 -m pip install --upgrade pip
~/Downloads/blender-4.2.2-linux-x64/4.2/python/bin$ ./pip3 install -U setuptools
~/Downloads/blender-4.2.2-linux-x64/4.2/python/bin$ ./pip3 install -U wheel

I also installed some dev package for Python 3.11 just in case:

$ sudo apt install libpython3.11-dev python3.11-dev

But it's not helping.

These are the packages installed locally in Blender
(located in ~/Downloads/blender-4.2.2-linux-x64/4.2/python/lib/python3.11/site-packages/):

~/Downloads/blender-4.2.2-linux-x64/4.2/python/bin$ ./pip3 list
Package            Version
------------------ ---------
autopep8           1.6.0
certifi            2021.10.8
charset-normalizer 2.0.10
Cython             0.29.30
idna               3.3
numpy              1.24.3
pip                24.2
pycodestyle        2.8.0
pyproj             3.6.1
requests           2.27.1
setuptools         75.1.0
toml               0.10.2
urllib3            1.26.8
wheel              0.44.0
zstandard          0.16.0

If possible, any hints are appreciated.

Thanks a lot!

Steps to reproduce the issue

See above.

Versions and provenance

Installed with apt on Ubuntu 22.04.5 LTS

$ gdalinfo --version
GDAL 3.4.1, released 2021/12/27

Additional context

No response

rouault commented 1 month ago

I guess the in /home/<username>/Downloads/blender-4.2.2-linux-x64/4.2/python/include/python3.11 is the result of your manual anonymization... ? Is there a Python.h file there, or in neighbour directories That's the key issue. Your blender package might lack the Python include files, and there's nothing GDAL can do about that Your workaround would be to manually copy it there from your system python3-dev package Or maybe set a CFLAGS environment variable to point to it or hack into GDAL's setup.py to reference it. Manually copying missing files is likely going to be the easier road I don't think it is a GDAL bug/responsibility to address that scenario

swiss-knight commented 1 month ago

Thank you @rouault 🙏!

I understand that this may not directly be related to GDAL itself but I wasn't 100% sure.

Yes indeed, I replaced the username by a placeholder.

Then, I cannot find any Python.h file in the whole Blender installation directory:

~/Downloads/blender-4.2.2-linux-x64$ find . -iname "*Python.h"

=> no results.

So I manually created the directory ~/Downloads/blender-4.2.2-linux-x64/4.2/python/include/python3.11/ and copied there the file /usr/include/python3.11/Python.h. It solves the current issue. But now I'm facing plenty of others missing header files...

So I basically copied both:

~/Downloads/blender-4.2.2-linux-x64/4.2/python/include$ cp /usr/include/python3.11/*.h ../python3.11/
~/Downloads/blender-4.2.2-linux-x64/4.2/python/include$ cp -R /usr/include/python3.11/cpython/ ../python3.11/

which where needed and then it succeeded compiling:

~/Downloads/blender-4.2.2-linux-x64/4.2/python/bin$ ./pip3 install gdal==3.4.1
Collecting gdal==3.4.1
  Using cached GDAL-3.4.1.tar.gz (755 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: gdal
  Building wheel for gdal (setup.py) ... done
  Created wheel for gdal: filename=GDAL-3.4.1-cp311-cp311-linux_x86_64.whl size=4236286 sha256=6178332f1b6a97a3cb4a6e74ad45685ce21ad1ea0616dd5920c2b0816440e43e
  Stored in directory: /home/<username>/.cache/pip/wheels/e9/71/fd/44c1a8ffcf965090e76f303dee7ee88bf5c3ec34d5d2803c90
Successfully built gdal
Installing collected packages: gdal
Successfully installed gdal-3.4.1

Hint: creating a symlink to /usr/include/python3.11/ at the ~/Downloads/blender-4.2.2-linux-x64/4.2/python/ level does also work perfectly. So there is no need to duplicates the header files.

Maybe I shall ping Blender's developers about including Python header files... Done: https://projects.blender.org/blender/blender/issues/128242

Thanks again!

Solved.