2
ImportError                               Traceback (most recent call last)
<ipython-input-20-3916336930a7> in <module>
----> 1 import geoplot

/opt/anaconda3/envs/TF/lib/python3.7/site-packages/geoplot/__init__.py in <module>
----> 1 from .geoplot import (
      2     pointplot, polyplot, choropleth, cartogram, kdeplot, sankey, voronoi, quadtree, webmap,
      3     __version__
      4 )
      5 from .crs import (

/opt/anaconda3/envs/TF/lib/python3.7/site-packages/geoplot/geoplot.py in <module>
     14 import shapely.geometry
     15 import pandas as pd
---> 16 from geopandas.plotting import _PolygonPatch as GeopandasPolygonPatch
     17 import contextily as ctx
     18 import mapclassify as mc

ImportError: cannot import name '_PolygonPatch' from 'geopandas.plotting' (/opt/anaconda3/envs/TF/lib/python3.7/site-packages/geopandas/plotting.py)

Hello, I would like to use geoplot, I get this error when I try to run it. I installed it with conda forge and pip but neither work. Here are some of the packages I have:

cartopy                   0.18.0           py37hf1ba7ce_1  
descartes                 1.1.0                    pypi_0    pypi
fiona                     1.8.13.post1     py37h9c05f0f_0  
geographiclib             1.52                     pypi_0    pypi
geopandas                 0.9.0                      py_1  
geopandas-base            0.9.0                      py_1  
geoplot                   0.4.3                    pypi_0    pypi
geopy                     2.2.0                    pypi_0    pypi
geos                      3.8.0                hb1e8313_0  

Please let me know if there's a specific package I need or if you know what's going on!

This is the result of help(geopandas.plotting):

plot_dataframe(df, column=None, cmap=None, color=None, ax=None, cax=None, categorical=False, legend=False, scheme=None, k=5, vmin=None, vmax=None, markersize=None, figsize=None, legend_kwds=None, categories=None, classification_kwds=None, missing_kwds=None, aspect='auto', **style_kwds)

plot_linestring_collection = old(*args, **kwargs)
    
plot_point_collection = old(*args, **kwargs)
    
plot_polygon_collection = old(*args, **kwargs)
    
plot_series(s, cmap=None, color=None, ax=None, figsize=None, aspect='auto', **style_kwds)

I am running python 3.7.7

Bigboss01
  • 438
  • 6
  • 21
  • From the error, I suspect you have an older `geopandas` installed somewhere (likely, `~/.local/lib/python3.7/site-packages/geopandas`) and this version is incompatible with `geoplot==0.4.3`. Please check `import geopandas; print(geopandas.__path__)` to check where it is loaded from. – merv Sep 10 '21 at 16:58
  • @merv hey merv, I checked the path and it's being loaded from the correct environment. I removed it and reinstalled it with pip and geoplot now works! I am unsure what the error was but it's resolved itself. Thanks for the advice, will definitely be helpful in the future. I suppose for a resolution of this kind I should just delete this question? – Bigboss01 Sep 11 '21 at 07:03
  • 2
    Glad you got it resolved! I think it's useful to retain the question, in case anyone else encounter such a situation. Feel free to document what you did as an answer - self-answers are always welcome. – merv Sep 12 '21 at 01:51

0 Answers0