10

I am getting the following error when importing

import geopandas as gpd

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last) 
<ipython-input-3-f8b81fe8ca07> in <module>()
----> 1 import geopandas as gpd

//anaconda/lib/python2.7/site-packages/geopandas/__init__.py in <module>()
  2 from geopandas.geodataframe import GeoDataFrame
  3 
----> 4 from geopandas.io.file import read_file
  5 from geopandas.io.sql import read_postgis
  6 from geopandas.tools import sjoin

//anaconda/lib/python2.7/site-packages/geopandas/io/file.py in <module>()
  1 import os
  2 
----> 3 import fiona
  4 import numpy as np
  5 from shapely.geometry import mapping

//anaconda/lib/python2.7/site-packages/fiona/__init__.py in <module>()
 67 from six import string_types
 68 
---> 69 from fiona.collection import Collection, BytesCollection, vsi_path
 70 from fiona._drivers import driver_count, GDALEnv
 71 from fiona.drvsupport import supported_drivers

 //anaconda/lib/python2.7/site-packages/fiona/collection.py in <module>()
  6 import warnings
  7 
----> 8 from fiona import compat
  9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
 10 from fiona.ogrext import Session, WritingSession

ImportError: cannot import name compat

I have installed geoPandas using anaconda however when I am trying to run it is displaying me the above error. When running

conda list

I am getting

enter image description here

After the runnning of the following:

conda install -c conda-forge fiona shapely pyproj rtree
conda install pandas
conda install -c conda-forge geopandas

I am getting

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-f8b81fe8ca07> in <module>()
----> 1 import geopandas as gpd

//anaconda/lib/python2.7/site-packages/geopandas/__init__.pyc in <module>()
  2 from geopandas.geodataframe import GeoDataFrame
  3 
----> 4 from geopandas.io.file import read_file
  5 from geopandas.io.sql import read_postgis
  6 from geopandas.tools import sjoin

//anaconda/lib/python2.7/site-packages/geopandas/io/file.py in <module>()
  1 import os
  2 
----> 3 import fiona
  4 import numpy as np
  5 from shapely.geometry import mapping

//anaconda/lib/python2.7/site-packages/fiona/__init__.py in <module>()
 67 from six import string_types
 68 
---> 69 from fiona.collection import Collection, BytesCollection, vsi_path
 70 from fiona._drivers import driver_count, GDALEnv
 71 from fiona.drvsupport import supported_drivers

//anaconda/lib/python2.7/site-packages/fiona/collection.py in <module>()
  7 
  8 from fiona import compat
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
 10 from fiona.ogrext import Session, WritingSession
 11 from fiona.ogrext import (

ImportError: dlopen(//anaconda/lib/python2.7/site-packages/fiona/ogrext.so,       

2): Library not loaded: @rpath/libnetcdf.11.dylib
  Referenced from: //anaconda/lib/libgdal.20.dylib
  Reason: Incompatible library version: libgdal.20.dylib requires version    

  12.0.0 or later, but libnetcdf.11.dylib provides version 11.0.0
Arshad
  • 351
  • 1
  • 2
  • 15
  • Could you try running: `conda install -c conda-forge fiona shapely pyproj rtree` and `conda install pandas` and `conda install -c conda-forge geopandas` – Ari Cooper-Davis Mar 12 '17 at 15:50
  • I have edited my question with the output I am getting now by running what you instructed. – Arshad Mar 12 '17 at 16:08
  • Try creating a new conda environment with minimal installs to see if it works. I couldn't get `geopandas` to run on my `root` conda install, but it did work on a new, minimal `conda` environment – cd98 Mar 13 '17 at 20:43

2 Answers2

11

The problem is caused by incompatibility of the fiona's and gdal's dependencies. Uninstall geopandas via conda. It will uninstall fiona as well. Do conda uninstall geopandas; Do conda install fiona=1.6

Do conda search fiona before hand and see if it is available for your version of python. If not, create new environment for that version of python.(Ex. create -n py35 python=3.5 anaconda)

Then pip install geopandas

Finally, try to import geopandas and see if you still get the error.

  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment](http://stackoverflow.com/help/privileges/comment) on any post. Also check this [what can I do instead](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). – thewaywewere May 03 '17 at 14:38
1

I had the same issue in MacOs Mojave 10.14. I found out that the solution is to install geopandas via pip instead of using conda

pip install geopandas
Galuoises
  • 2,630
  • 24
  • 30