[gdal-dev] gdal_calc.py Does Not Work on Mac

Andreas Oxenstierna andreas.oxenstierna at t-kartor.com
Mon Jun 27 23:28:01 PDT 2022


Hi

My gdal installation with brew, https://formulae.brew.sh/formula/gdal,  do work on macOS:
which gdal_calc.py
/usr/local/bin/gdal_calc.py

ls -l /usr/local/bin/gdal_calc*
/usr/local/bin/gdal_calc.py -> ../Cellar/gdal/3.3.2_3/bin/gdal_calc.py

Do you have to use Anaconda?

Best Regards

Andreas Oxenstierna
T-Kartor Geospatial AB
Olof Mohlins väg 12 Kristianstad
mobile: +46 733 206831
mailto: andreas.oxenstierna at t-kartor.com<mailto:andreas.oxenstierna at t-kartor.com>
www.t-kartor.com<http://www.t-kartor.com>
On 28 Jun 2022, 05:19 +0200, Chao Li <chaoli0394 at gmail.com>, wrote:
Hi,

I meet a problem when I use gdal_calc.py on mac:


(base) lichao at riushios-MacBook-Pro ~ % gdal_calc.py

Traceback (most recent call last):

  File "/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/osgeo/__init__.py", line 29, in swig_import_helper

    return importlib.import_module(mname)

  File "/Users/lichao/opt/anaconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import

  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load

  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked

  File "<frozen importlib._bootstrap>", line 565, in module_from_spec

  File "<frozen importlib._bootstrap_external>", line 1173, in create_module

  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed

ImportError: dlopen(/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/osgeo/_gdal.cpython-39-darwin.so<http://gdal.cpython-39-darwin.so>, 0x0002): Library not loaded: @rpath/libpoppler.91.dylib

  Referenced from: /Users/lichao/opt/anaconda3/lib/libgdal.30.dylib

  Reason: tried: '/Users/lichao/opt/anaconda3/lib/libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/lib/libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/lib/libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/osgeo/../../../libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/lib/libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/lib/libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/osgeo/../../../libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/lib/libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/bin/../lib/libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/lib/libpoppler.91.dylib' (no such file), '/Users/lichao/opt/anaconda3/bin/../lib/libpoppler.91.dylib' (no such file), '/usr/local/lib/libpoppler.91.dylib' (no such file), '/usr/lib/libpoppler.91.dylib' (no such file)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/Users/lichao/opt/anaconda3/bin/gdal_calc.py", line 4, in <module>

    __import__('pkg_resources').run_script('GDAL==3.4.1', 'gdal_calc.py')

  File "/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/pkg_resources/__init__.py", line 662, in run_script

    self.require(requires)[0].run_script(script_name, ns)

  File "/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1459, in run_script

    exec(code, namespace, namespace)

  File "/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/GDAL-3.4.1-py3.9-macosx-10.9-x86_64.egg-info/scripts/gdal_calc.py", line 5, in <module>

    from osgeo_utils.gdal_calc import *  # noqa

  File "/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/osgeo_utils/gdal_calc.py", line 46, in <module>

    from osgeo import gdal

  File "/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/osgeo/__init__.py", line 45, in <module>

    _gdal = swig_import_helper()

  File "/Users/lichao/opt/anaconda3/lib/python3.9/site-packages/osgeo/__init__.py", line 42, in swig_import_helper

    return importlib.import_module('_gdal')

  File "/Users/lichao/opt/anaconda3/lib/python3.9/importlib/__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

ModuleNotFoundError: No module named '_gdal'


(base) lichao at riushios-MacBook-Pro ~ % which gdal_calc.py

/Users/lichao/opt/anaconda3/bin/gdal_calc.py


(base) lichao at riushios-MacBook-Pro ~ % gdal-config --version

3.4.1


Thanks for your help.


Best

--
------------------------------------------------------------------------------------
Mike Li
Department of Urban and Environmental Engineering
Graduate School of Engineering
Kyushu University
744 Motooka, Nishi-ku, Fukuoka 819-0395 Japan
Tel: 090-8304-8953
E-mail: chaoli0394 at gmail.com<mailto:chaoli0394 at gmail.com>
-------------------------------------------------------------------------------------
李潮(リ チョウ)
九州大学 大学院 工学府 都市環境システム工学専攻
都市工学研究室
-------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220628/1df82440/attachment-0001.htm>


More information about the gdal-dev mailing list