Reputation: 21
I have Colab project that uses h3pandas
for polyfill, but importing h3pandas
throws an ImportError.
After adding these libraries:
!pip install h3pandas
import pandas as pd
import matplotlib.pyplot as plt
import h3pandas
I get this error:
ImportError Traceback (most recent call last)
<ipython-input-2-5e53e9308d98> in <cell line: 3>()
1 import pandas as pd
2 import matplotlib.pyplot as plt
----> 3 import h3pandas
1 frames
/usr/local/lib/python3.10/dist-packages/h3pandas/h3pandas.py in <module>
9 import geopandas as gpd
10
---> 11 from h3 import h3
12 from pandas.core.frame import DataFrame
13 from geopandas.geodataframe import GeoDataFrame`
ImportError: cannot import name 'h3' from 'h3' (/usr/local/lib/python3.10/dist-packages/h3/__init__.py)
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
Upvotes: 2
Views: 656
Reputation: 1885
This is a known bug in H3-Pandas. As of h3-py v4.0.0, the name h3.h3
no longer exists, so the line from h3 import h3
in the H3-Pandas source code throws an ImportError.
As a workaround, you can manually install a version of H3 that still includes that name. Any v3 release will work - at the time of this writing, the most recent is v3.7.7, but you can also just pip install h3~=3.0
.
!pip install h3pandas
!pip install h3~=3.0
import pandas as pd
import matplotlib.pyplot as plt
import h3pandas
Upvotes: 1