0
$\begingroup$

I am trying to install GDAL to use it with BlenderGis, but I am not able to run it. I have Python installed with brew.

I tried a similar flow as described here for Mac: https://github.com/domlysz/BlenderGIS/wiki/How-to-install-GDAL

When I run from osgeo import gdal I get:

/Applications/Blender.app/Contents/MacOS/Blender
^[[C^[[CError: Python: Traceback (most recent call last):
  File "/Text", line 1, in <module>
ModuleNotFoundError: No module named 'osgeo'

I found my python installation here: /opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/

I did this to copy it:

cp -rf /opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/osgeo/ /Applications/Blender.app/Contents/Resources/3.6/scripts/modules/

After that I tried to copy it into folders to modules/osgeo and now I am getting this error:

DEBUG:BlenderGIS-228.core.checkdeps:GDAL Python binding unavailable
DEBUG:BlenderGIS-228.core.checkdeps:PyProj unavailable
DEBUG:BlenderGIS-228.core.checkdeps:Pillow unavailable
DEBUG:BlenderGIS-228.core.checkdeps:ImageIO Freeimage plugin available
Error: Python: Traceback (most recent call last):
  File "/Applications/Blender.app/Contents/Resources/3.6/scripts/modules/osgeo/__init__.py", line 30, in swig_import_helper
    return importlib.import_module(mname)
  File "/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'osgeo._gdal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Text", line 1, in <module>
  File "/Applications/Blender.app/Contents/Resources/3.6/scripts/modules/osgeo/__init__.py", line 35, in <module>
    _gdal = swig_import_helper()
  File "/Applications/Blender.app/Contents/Resources/3.6/scripts/modules/osgeo/__init__.py", line 32, in swig_import_helper
    return importlib.import_module('_gdal')
  File "/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_gdal'

Please, any idea how to make it working?

Edit 2023-08-13: I tried to run /Applications/Blender.app/Contents/Resources/3.6/python/bin/pip3 install gdal

But getting error:

/Applications/Blender.app/Contents/Resources/3.6/python/bin/pip3 install gdal
Collecting gdal
  Using cached GDAL-3.7.1.1.tar.gz (776 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
  ╰─> [182 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-11.00-arm64-cpython-310
      creating build/lib.macosx-11.00-arm64-cpython-310/osgeo
      copying osgeo/gnm.py -> build/lib.macosx-11.00-arm64-cpython-310/osgeo
 ...
      creating var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn
      creating var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c /var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmpy53sf_2s.cpp -o var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmpy53sf_2s.o -Wno-error=unused-command-line-argument-hard-error-in-future
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      1 warning generated.
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c /var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmp_txcjv3e.cpp -o var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmp_txcjv3e.o -Wno-error=unused-command-line-argument-hard-error-in-future
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      1 warning generated.
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c /var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmps7suvkhh.cpp -o var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmps7suvkhh.o -Wno-error=unused-command-line-argument-hard-error-in-future
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      1 warning generated.
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c /var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmpk2r8008m.cpp -o var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmpk2r8008m.o -Wno-error=unused-command-line-argument-hard-error-in-future
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      1 warning generated.
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c /var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmp_fh4vxo4.cpp -o var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmp_fh4vxo4.o -Wno-error=unused-command-line-argument-hard-error-in-future
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      1 warning generated.
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c /var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmplb3ylobc.cpp -o var/folders/5y/1mtr8g5d22z7m61s_46gjwv80000gn/T/tmplb3ylobc.o -Wno-error=unused-command-line-argument-hard-error-in-future
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      1 warning generated.
      building 'osgeo._gdal' extension
      building 'osgeo._gdalconst' extension
      building 'osgeo._osr' extension
      building 'osgeo._ogr' extension
      creating build/temp.macosx-11.00-arm64-cpython-310
      building 'osgeo._gnm' extension
      creating build/temp.macosx-11.00-arm64-cpython-310/extensions
      creating build/temp.macosx-11.00-arm64-cpython-310/extensions
      building 'osgeo._gdal_array' extension
      creating build/temp.macosx-11.00-arm64-cpython-310/extensions
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-11.00-arm64-cpython-310/extensions/gdal_wrap.o -std=c++11 -Wno-error=unused-command-line-argument-hard-error-in-future -I/opt/homebrew/Cellar/gdal/3.7.1_1/include
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c extensions/gdalconst_wrap.c -o build/temp.macosx-11.00-arm64-cpython-310/extensions/gdalconst_wrap.o -Wno-error=unused-command-line-argument-hard-error-in-future -I/opt/homebrew/Cellar/gdal/3.7.1_1/include
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c extensions/osr_wrap.cpp -o build/temp.macosx-11.00-arm64-cpython-310/extensions/osr_wrap.o -std=c++11 -Wno-error=unused-command-line-argument-hard-error-in-future -I/opt/homebrew/Cellar/gdal/3.7.1_1/include
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c extensions/gdal_array_wrap.cpp -o build/temp.macosx-11.00-arm64-cpython-310/extensions/gdal_array_wrap.o -std=c++11 -Wno-error=unused-command-line-argument-hard-error-in-future -I/opt/homebrew/Cellar/gdal/3.7.1_1/include
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c extensions/gnm_wrap.cpp -o build/temp.macosx-11.00-arm64-cpython-310/extensions/gnm_wrap.o -std=c++11 -Wno-error=unused-command-line-argument-hard-error-in-future -I/opt/homebrew/Cellar/gdal/3.7.1_1/include
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Users/brecht/dev/build_darwin/deps/Release/sqlite/include -I/Users/brecht/dev/build_darwin/deps/Release/bzip2/include -I/Users/brecht/dev/build_darwin/deps/Release/lzma/include -I/Users/brecht/dev/build_darwin/deps/Release/zlib/include -mmacosx-version-min=11.00 -arch arm64 -mmacosx-version-min=11.00 -arch arm64 -I/Users/brecht/dev/build_darwin/deps/Release/python/include/python3.10 -I/Applications/Blender.app/Contents/Resources/3.6/python/lib/python3.10/site-packages/numpy/core/include -I/opt/homebrew/Cellar/gdal/3.7.1_1/include -c extensions/ogr_wrap.cpp -o build/temp.macosx-11.00-arm64-cpython-310/extensions/ogr_wrap.o -std=c++11 -Wno-error=unused-command-line-argument-hard-error-in-future -I/opt/homebrew/Cellar/gdal/3.7.1_1/include
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
      extensions/gdalconst_wrap.c:156:11: fatal error: 'Python.h' file not found
      # include <Python.h>
                ^~~~~~~~~~
      extensions/gdal_array_wrap.cpp:179:11: fatal error: 'Python.h' file not found
      # include <Python.h>
                ^~~~~~~~~~
      extensions/gnm_wrap.cpp:180:11: fatal error: 'Python.h' file not found
      # include <Python.h>
                ^~~~~~~~~~
      extensions/osr_wrap.cpp:180:11: fatal error: 'Python.h' file not found
      # include <Python.h>
                ^~~~~~~~~~
      extensions/gdal_wrap.cpp:180:11: fatal error: 'Python.h' file not found
      # include <Python.h>
                ^~~~~~~~~~
      extensions/ogr_wrap.cpp:180:11: fatal error: 'Python.h' file not found
      # include <Python.h>
                ^~~~~~~~~~
      1 warning and 1 error generated.
      1 warning and 1 error generated.
      1 warning and 1 error generated.
      1 warning and 1 error generated.
      1 warning and 1 error generated.
      1 warning and 1 error generated.
      error: command '/usr/bin/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
ERROR: Could not build wheels for gdal, which is required to install pyproject.toml-based projects

I tried to fix it with: Python.h missing in Blender Python? but without success.

$\endgroup$
5
  • $\begingroup$ you can install blender python modules using pip. u have to install them using the scripting tab inside blender because blender is bundled with its own python version, independent of your system-wide python. $\endgroup$
    – Harry McKenzie
    Commented Aug 13, 2023 at 13:05
  • $\begingroup$ I tried this and I am getting error when trying to install gdal with command /Applications/Blender.app/Contents/Resources/3.6/python/bin/pip3 install gdal error: extensions/gdalconst_wrap.c:156:11: fatal error: 'Python.h' file not found # include <Python.h> $\endgroup$
    – Dawe
    Commented Aug 13, 2023 at 13:39
  • $\begingroup$ I tried to follow this guide blender.stackexchange.com/a/107381/172085 but still not success. $\endgroup$
    – Dawe
    Commented Aug 13, 2023 at 13:41
  • $\begingroup$ no do it inside of blender Text Editor in the scripting tab $\endgroup$
    – Harry McKenzie
    Commented Aug 13, 2023 at 14:25
  • $\begingroup$ @HarryMcKenzie it is giving me the same error fatal error: 'Python.h' file not found # include <Python.h> $\endgroup$
    – Dawe
    Commented Aug 13, 2023 at 14:36

1 Answer 1

1
$\begingroup$

So I was able to fix it by running this:

/Applications/Blender.app/Contents/Resources/3.6/python/bin/pip3 install --upgrade setuptools

This thread helped https://github.com/pypa/packaging-problems/issues/573

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .