Skip to content

Instantly share code, notes, and snippets.

@shravan-kuchkula
Last active November 22, 2021 20:45
Show Gist options
  • Save shravan-kuchkula/778e90eef818aa955676963c0132f08b to your computer and use it in GitHub Desktop.
Save shravan-kuchkula/778e90eef818aa955676963c0132f08b to your computer and use it in GitHub Desktop.
How to install geopandas library?

How to install geopandas library on macOS?

I suggest you create a brand new environment before starting.

Ensure that when you create a conda env, you don't use default packages. You will thank yourself later.

  conda create --no-default-packages -n geo_pandas python=3.7
  conda activate geo_pandas
  conda config --env --add channels conda-forge
  conda config --env --set channel_priority strict (This is optional)
  

install geopandas

  conda install -c conda-forge geopandas

You think that this will take care of all the dependencies for us. Not really! It appears that the version of fiona that geopandas depends on does not get installed correctly. (As of this writing, that is)

test geopandas

This will fail gloriously saying image not found.

$ python
Python 3.7.4 (default, Aug 13 2019, 15:17:50)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import geopandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Shravan/anaconda3/envs/geo_pandas/lib/python3.7/site-packages/geopandas/__init__.py", line 5, in <module>
    from geopandas.io.file import read_file
  File "/Users/Shravan/anaconda3/envs/geo_pandas/lib/python3.7/site-packages/geopandas/io/file.py", line 4, in <module>
    import fiona
  File "/Users/Shravan/anaconda3/envs/geo_pandas/lib/python3.7/site-packages/fiona/__init__.py", line 83, in <module>
    from fiona.collection import BytesCollection, Collection
  File "/Users/Shravan/anaconda3/envs/geo_pandas/lib/python3.7/site-packages/fiona/collection.py", line 9, in <module>
    from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: dlopen(/Users/Shravan/anaconda3/envs/geo_pandas/lib/python3.7/site-packages/fiona/ogrext.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libpoppler.76.dylib
  Referenced from: /Users/Shravan/anaconda3/envs/geo_pandas/lib/libgdal.20.dylib
  Reason: image not found

OK, so install fiona again and test geopandas

conda install -c conda-forge fiona

This will downgrade some of the already install packages, don't worry.

(geo_pandas) Shravan: airbnb_nyc$ python
Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 14:38:56)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import geopandas
>>> print(geopandas.__version__)
0.5.1

Install jupyter (since i started from a clean slate, i didn't have jupyter either)

(geo_pandas) Shravan: airbnb_nyc$ conda install jupyter

OKAY, you also need "descrates"

Apparently, this module doesn't get install through package dependencies. So, when running your notebook, you will get an error saying "descrates" not found. At that point, close your eyes and run conda install -c conda-forge descartes. You will be all set.

(geo_pandas) Shravan: raw$ conda install -c conda-forge descartes
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.4.10
  latest version: 4.7.12

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: /Users/Shravan/anaconda3/envs/geo_pandas

  added / updated specs:
    - descartes


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    descartes-1.1.0            |             py_3           6 KB  conda-forge

The following NEW packages will be INSTALLED:

    descartes: 1.1.0-py_3 conda-forge

Proceed ([y]/n)? y


Downloading and Extracting Packages
descartes 1.1.0: ##################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(geo_pandas) Shravan: raw$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment