2

I'm having this issue when I try to use the Polygonise(raster to vector) tool in QGIS 3.4.3 (Madeira) on a Mac running Mojave:

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

from osgeo import gdal

ImportError: No module named osgeo

Some others have discussed this before and with reference to QGIS 3.0 error when start in MacOS High Sierra, I note that I don't seem to have the /Python/3.6/site-packages sub-branch in my

/Library/Frameworks/GEOS.framework/Versions/3B/
/Library/Frameworks/GDAL.framework/Versions/2.3/

directories. I definitely have Python 3.6 (and not 3.7) installed.

To try to fix, I've reinstalled Python 3.6.8 using the installer from Python.org and I've reinstalled QGIS 3.4.3. Following these reinstalls, I still don't have the directory branches mentioned above and the Polygonise tool still doesn't work.

My presumption is that the lack of these branches is causing the problem (but I could be wrong).

What do I need to do to sort this out?

1 Answer 1

1

If you are uncertain whether Python 2 or Python 3 is being used, try python3, then issue the command import from osgeo import gdal.

roblabs@27:~ $ python3
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import from osgeo import gdal
>>> from osgeo import gdal
>>> # No response, nor errors => good news

That just worked for me on macOS. Your script that is calling the library gdal_polygonize.py is likely using macOS's installed version of Python 2, python.

You can also add #!/usr/local/bin/python3 to the top of your script.py to explicitly use python3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.