0

I'm running Django rest api with the django 3.2 on GCPUbuntu 20.04.5 LTS (GNU/Linux 5.15.0-1025-gcp x86_64).I'm getting an error when i execute pip3 install gdal==3.6.2. I need to use GDAL in one of my project modules. I have also installed

sudo apt-get install gdal-bin --upgrade 
sudo apt install libgdal-dev --upgrade

gdal config version shows :

gdal-config --version
2.4.2

Here is my Error trace :

pip3 install gdal==3.6.2
Collecting gdal==3.6.2
  Using cached GDAL-3.6.2.tar.gz (757 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
  ╰─> [151 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/ogr.py -> build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/gdalconst.py -> build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/gdal.py -> build/lib.linux-x86_64-cpython-38/osgeo
      
      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/usr/include/python3.8 -I/home/myEnv/lib/python3.8/site-packages/numpy/core/include -I/usr/include -c extensions/gdalconst_wrap.c -o build/temp.linux-x86_64-cpython-38/extensions/gdalconst_wrap.o -I/usr/include/gdal
      extensions/osr_wrap.cpp:180:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      compilation terminated.
      building 'osgeo._gnm' extension
      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/usr/include/python3.8 -I/home/myEnv/lib/python3.8/site-packages/numpy/core/include -I/usr/include -c extensions/gnm_wrap.cpp -o build/temp.linux-x86_64-cpython-38/extensions/gnm_wrap.o -I/usr/include/gdal
      extensions/gdal_wrap.cpp:180:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      compilation terminated.
      extensions/gdalconst_wrap.c:156:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      building 'osgeo._gdal_array' extension
      compilation terminated.
      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/usr/include/python3.8 -I/home/myEnv/lib/python3.8/site-packages/numpy/core/include -I/usr/include -c extensions/gdal_array_wrap.cpp -o build/temp.linux-x86_64-cpython-38/extensions/gdal_array_wrap.o -I/usr/include/gdal
      extensions/ogr_wrap.cpp:180:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      compilation terminated.
      extensions/gnm_wrap.cpp:180:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      compilation terminated.
      extensions/gdal_array_wrap.cpp:179:11: fatal error: Python.h: No such file or directory
       # 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 gdal
  Running setup.py clean for gdal
Failed to build gdal
Installing collected packages: gdal
  Running setup.py install for gdal ... error
  error: subprocess-exited-with-error
  
 × Running setup.py install for gdal did not run successfully.
  │ exit code: 1
  ╰─> [152 lines of output]
      running install
      /home/myEnv/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/ogr.py -> build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/gdalconst.py -> build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/gdal.py -> build/lib.linux-x86_64-cpython-38/osgeo × Running setup.py install for gdal did not run successfully.
  │ exit code: 1
  ╰─> [152 lines of output]
      running install
      /home/myEnv/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-38
      creating build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/ogr.py -> build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/gdalconst.py -> build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-cpython-38/osgeo
      copying osgeo/gdal.py -> build/lib.linux-x86_64-cpython-38/osgeo
      
      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/usr/include/python3.8 -I/home/myEnv/lib/python3.8/site-packages/numpy/core/include -I/usr/include -c extensions/osr_wrap.cpp -o build/temp.linux-x86_64-cpython-38/extensions/osr_wrap.o -I/usr/include/gdal
      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/usr/include/python3.8 -I/home/myEnv/lib/python3.8/site-packages/numpy/core/include -I/usr/include -c extensions/ogr_wrap.cpp -o build/temp.linux-x86_64-cpython-38/extensions/ogr_wrap.o -I/usr/include/gdal
      extensions/gdal_wrap.cpp:180:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      compilation terminated.
      building 'osgeo._gnm' extension
      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/usr/include/python3.8 -I/home/myEnv/lib/python3.8/site-packages/numpy/core/include -I/usr/include -c extensions/gnm_wrap.cpp -o build/temp.linux-x86_64-cpython-38/extensions/gnm_wrap.o -I/usr/include/gdal
      extensions/osr_wrap.cpp:180:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      compilation terminated.
      extensions/gdalconst_wrap.c:156:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      compilation terminated.
      building 'osgeo._gdal_array' extension
      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/usr/include/python3.8 -I/home/myEnv/lib/python3.8/site-packages/numpy/core/include -I/usr/include -c extensions/gdal_array_wrap.cpp -o build/temp.linux-x86_64-cpython-38/extensions/gdal_array_wrap.o -I/usr/include/gdal
      extensions/ogr_wrap.cpp:180:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      compilation terminated.
      extensions/gnm_wrap.cpp:180:11: fatal error: Python.h: No such file or directory
       # include <Python.h>
                 ^~~~~~~~~~
      compilation terminated.
      extensions/gdal_array_wrap.cpp:179:11: fatal error: Python.h: No such file or directory
       # 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: legacy-install-failure

× Encountered error while trying to install package.
╰─> gdal

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
  

I have ignored some copy statements from the trace due to stack character limitation(30000).

Help appreciated.

Earthling
  • 83
  • 3
  • 13

0 Answers0