homebrew-osgeo4mac: error when running gdal merge

Hi! I’m having issues when running the gdal merge tool from latest osgeo4mac QGIS 3.4.4 on MacOS Mojave. It’s strange because other gdal tools run well, but when I run the mosaic I get this error:

2019-02-11T18:25:17     INFO    gdal_merge.py -ot Float32 -of GTiff -o /private/var/folders/fc/8d63rgj567954sphjm_18jxc0000gn/T/processing_b134aaed11d54580be7a0a55892749b4/852f65f2e4174785a1b7b8edc21053e9/OUTPUT.tif --optfile /private/var/folders/fc/8d63rgj567954sphjm_18jxc0000gn/T/processing_b134aaed11d54580be7a0a55892749b4/mergeInputFiles.txt
2019-02-11T18:25:17     INFO    GDAL execution console output
             Traceback (most recent call last):

              File "/usr/local/opt/gdal2-python/bin/gdal_merge.py", line 38, in 

              from osgeo import gdal

              File "/usr/local/opt/gdal2-python/lib/python3.7/site-packages/osgeo/__init__.py", line 21, in 

              _gdal = swig_import_helper()

              File "/usr/local/opt/gdal2-python/lib/python3.7/site-packages/osgeo/__init__.py", line 13, in swig_import_helper

              import _gdal

             ImportError: No module named _gdal

I already checked those directories and the .py files are there, so I’m wondering what can be causing this error. Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (1 by maintainers)

Most upvoted comments

@GuiAlDuS What kind of problems are you having? do you mean others?

If you are installing.

To rule out any problem you have in your homebrew installation:

$ brew unlink python && brew link --force python
$ brew reinstall ninja gsl python qt sip-qt5 pyqt-qt5 pyqt5-webkit qscintilla2-qt5 six bison flex pkg-config
$ brew link --overwrite pyqt-qt5
$ brew unlink gettext && brew link --force gettext
$ rm -rf $(brew --cache)

and the temporary build files in /tmp

An installation that failed previously may have created this link

   /usr/local/lib/python3.7/site-packages/PyQt5/uic/widget-plugins/qgis_customwidgets.py

you will need to delete it.

If you are going to use several flags, make sure that the system can open the necessary number of files.

$ ulimit -n 1024

If you only use qgis without flags, you do not need to build, will use the generated bottle.

p/d: keep in mind that if it is built in CI, it should be built on any other machine. If your installation fails, it is due to your Homebrew environment, review it.

@GuiAlDuSFormula updated, problems solved! 🎉

@GuiAlDuS I will implement the solution, verified and it works.

I have tried merge and polygonize. Everything seems to work correctly!

gdal gdal2

in the course of the day I will fix this!

@GuiAlDuS @PeterPetrik @saberraz 🎉 I already found a solution for this, I will comment. Before I need to see what happens in Travis, building bottles.

gdal

Thanks! Just in case it’s needed, this is the info of the versions I have:

osgeo/osgeo4mac/gdal2-python: stable 2.4.0 (bottled), HEAD [keg-only]
Python bindings for GDAL: Geospatial Data Abstraction Library
https://pypi.python.org/pypi/GDAL
/usr/local/Cellar/gdal2-python/2.4.0 (141 files, 6.7MB)
  Poured from bottle on 2019-02-07 at 16:06:30
From: https://github.com/osgeo/homebrew-osgeo4mac/blob/master/Formula/gdal2-python.rb
osgeo/osgeo4mac/qgis: stable 3.4.4, HEAD
Open Source Geographic Information System
https://www.qgis.org
/usr/local/Cellar/qgis/3.4.4_2 (5,766 files, 246.3MB) *
  Built from source on 2019-02-07 at 21:40:50 with: --with-grass --with-saga
From: https://github.com/osgeo/homebrew-osgeo4mac/blob/master/Formula/qgis.rb

Thanks FJ! I’ll be checking for the updates.

Just in case it’s important for the debugging, I had the same issue with the Polygonize (raster to vector) tool:

GDAL command:
gdal_polygonize.py /private/var/folders/fc/8d63rgj567954sphjm_18jxc0000gn/T/processing_9c3099bdd4a542bcb0d85f965c021096/d23e2d00703b4770a7a155993d12ed56/WSHED.sdat /private/var/folders/fc/8d63rgj567954sphjm_18jxc0000gn/T/processing_9c3099bdd4a542bcb0d85f965c021096/eb1090891c8743b0964ac5bbbbc4bf7b/OUTPUT.shp -b 1 -f "ESRI Shapefile" OUTPUT DN
GDAL command output:
Traceback (most recent call last):

File "/usr/local/opt/gdal2-python/bin/gdal_polygonize.py", line 36, in <module>

from osgeo import gdal

File "/usr/local/opt/gdal2-python/lib/python3.7/site-packages/osgeo/__init__.py", line 21, in <module>

_gdal = swig_import_helper()

File "/usr/local/opt/gdal2-python/lib/python3.7/site-packages/osgeo/__init__.py", line 13, in swig_import_helper

import _gdal

ImportError: No module named _gdal

I am rebuilding bottles and applying changes in several formulas.

Just wait a couple of hours, I’ll solve it.