Install gdal using conda?

I used

conda install gdal 

to install the GDAL packages. But an error occurred while importing the packages.

 >>> from osgeo import gdal Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 21, in <module> _gdal = swig_import_helper() File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 17, in swig_import_helper _mod = imp.load_module('_gdal', fp, pathname, description) ImportError: dlopen(/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so, 2): Library not loaded: libgdal.20.dylib Referenced from: /Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so Reason: image not found >>> from osgeo import ogr Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 21, in <module> _gdal = swig_import_helper() File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 17, in swig_import_helper _mod = imp.load_module('_gdal', fp, pathname, description) ImportError: dlopen(/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so, 2): Library not loaded: libgdal.20.dylib Referenced from: /Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so Reason: image not found 

What should I do to import GDAL into Python?

+12
python gdal
source share
3 answers

For Windows users (as of December 2015):

 conda install gdal conda upgrade numpy 

Installing gdal will decrease the number, so update it. Recently I had to use windows to change, and I was pleasantly surprised that gdal "works" easily now.

Windows + python + gis people around the world should celebrate this. (that gdal-python easily enters windows ... not that windows are one step closer to Linux;))

+17
source share

you can also use conda-forge channel

 conda install -c conda-forge gdal 

as shown on the anaconda website .

+4
source share

I used

 conda install -c conda-forge gdal 

On a Fedora 30 machine, and that led me to the hellish path of library conflict!

 conda install gdal 

worked on my first attempt

0
source share

All Articles