Geopandas: BUG: Geopandas 0.8.1 does not work with pygeos 0.9 on Python 3.7.3

Created on 25 Jan 2021  Â·  9Comments  Â·  Source: geopandas/geopandas

  • [x] I have checked that this issue has not already been reported.

  • [x] I have confirmed this bug exists on the latest version of geopandas.

  • [ ] (optional) I have confirmed this bug exists on the master branch of geopandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import geopandas

Problem description

I installed geopandas and pygeos on a fresh virtual environment with Python 3.7.3 on Debian 10.
When I try to import geopandas I got ```KeyError: 'MISSING'````


Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import geopandas

/home/my_home/python/deflex37_bug/lib/python3.7/site-packages/geopandas/_compat.py:88: UserWarning: The Shapely GEOS version (3.8.0-CAPI-1.13.1 ) is incompatible with the GEOS version PyGEOS was compiled with (3.9.0-CAPI-1.16.2). Conversions between both will be slow.
  shapely_geos_version, geos_capi_version_string
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/my_home/python/deflex37_bug/lib/python3.7/site-packages/geopandas/__init__.py", line 3, in <module>
    from geopandas.geoseries import GeoSeries  # noqa
  File "/home/my_home/python/deflex37_bug/lib/python3.7/site-packages/geopandas/geoseries.py", line 12, in <module>
    from geopandas.base import GeoPandasBase, _delegate_property
  File "/home/my_home/python/deflex37_bug/lib/python3.7/site-packages/geopandas/base.py", line 13, in <module>
    from .array import GeometryArray, GeometryDtype
  File "/home/my_home/python/deflex37_bug/lib/python3.7/site-packages/geopandas/array.py", line 25, in <module>
    from . import _vectorized as vectorized
  File "/home/my_home/python/deflex37_bug/lib/python3.7/site-packages/geopandas/_vectorized.py", line 39, in <module>
    type_mapping = {p.value: _names[p.name] for p in pygeos.GeometryType}
  File "/home/my_home/python/deflex37_bug/lib/python3.7/site-packages/geopandas/_vectorized.py", line 39, in <dictcomp>
    type_mapping = {p.value: _names[p.name] for p in pygeos.GeometryType}
KeyError: 'MISSING'

Expected Output

Nothing

Output of geopandas.show_versions()

It does not work because the import fails already.

Traceback (most recent call last):
File "", line 1, in
NameError: name 'geopandas' is not defined

bug

Most helpful comment

0.8.2 is released, on PyPI, conda-forge will follow soon

All 9 comments

I was about to submit this bug too :-) I came across this Yesterday. My workaround was to edit geopandas/_vectorized.py as follows:

_names = {
"MISSING":None,
"NAG": None,
"POINT": "Point",
"LINESTRING": "LineString",
"LINEARRING": "LinearRing",
"POLYGON": "Polygon",
"MULTIPOINT": "MultiPoint",
"MULTILINESTRING": "MultiLineString",
"MULTIPOLYGON": "MultiPolygon",
"GEOMETRYCOLLECTION": "GeometryCollection",
}

Basically, I added the entry

"MISSING":None

to _names.

The details of the issue that I used to have are below

import geopandas
Traceback (most recent call last):
  File "", line 1, in
  File "/Users/lquesada/Py39env/lib/python3.9/site-packages/geopandas/__init__.py", line 3, in
    from geopandas.geoseries import GeoSeries  # noqa
  File "/Users/lquesada/Py39env/lib/python3.9/site-packages/geopandas/geoseries.py", line 12, in
    from geopandas.base import GeoPandasBase, _delegate_property
  File "/Users/lquesada/Py39env/lib/python3.9/site-packages/geopandas/base.py", line 13, in
    from .array import GeometryArray, GeometryDtype
  File "/Users/lquesada/Py39env/lib/python3.9/site-packages/geopandas/array.py", line 25, in
    from . import _vectorized as vectorized
  File "/Users/lquesada/Py39env/lib/python3.9/site-packages/geopandas/_vectorized.py", line 39, in
    type_mapping = {p.value: _names[p.name] for p in pygeos.GeometryType}
  File "/Users/lquesada/Py39env/lib/python3.9/site-packages/geopandas/_vectorized.py", line 39, in
    type_mapping = {p.value: _names[p.name] for p in pygeos.GeometryType}
KeyError: 'MISSING'

(Py39env) insight086:~ lquesada$ python --version
Python 3.9.1

(Py39env) insight086:~ lquesada$ pip show geopandas
Name: geopandas
Version: 0.8.1
Summary: Geographic pandas extensions
Home-page: http://geopandas.org
Author: GeoPandas contributors
Author-email: [email protected]
License: BSD
Location: /Users/lquesada/Py39env/lib/python3.9/site-packages
Requires: shapely, pandas, fiona, pyproj
Required-by:

(Py39env) insight086:~ lquesada$ pip show pygeos
Name: pygeos
Version: 0.9
Summary: GEOS wrapped in numpy ufuncs
Home-page: https://github.com/pygeos/pygeos
Author: Casper van der Wel
Author-email: [email protected]
License: BSD 3-Clause
Location: /Users/lquesada/Py39env/lib/python3.9/site-packages
Requires: numpy
Required-by:



Ah, damn, this is fixed in master (https://github.com/geopandas/geopandas/pull/1641, https://github.com/geopandas/geopandas/pull/1644), but we forgot about that it would also impact released geopandas if a new pygeos released happened first (which happened yesterday).

So the easiest might be to do a quick/small geopandas 0.8.2 release with just this fix (or a pygeos bugfix release adding it back)

A quick little version kick would be awesome. That sounds like a frustrating little cat mouse game ha ha

Is locking pygeos==0.8 and geopandas==0.8.1 safe? thanks

@lepchenkov it is a safe short-term solution. We'll fix this in 0.8.2 soon.

0.8.2 is released, on PyPI, conda-forge will follow soon

That was super fast! Thank you for the quick fix.

On Mon, Jan 25, 2021 at 2:57 PM Joris Van den Bossche <
[email protected]> wrote:

0.8.2 is released, on PyPI, conda-forge will follow soon

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/geopandas/geopandas/issues/1793#issuecomment-767107481,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAD6HDUYBXJPGUHMD7HAU3DS3XLLBANCNFSM4WRQGOHA
.

>

-Seth

0.8.2 works fine for me too. Thanks a lot! Cheers

I think we can close this now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dzanaga picture dzanaga  Â·  3Comments

rutgerhofste picture rutgerhofste  Â·  4Comments

linwoodc3 picture linwoodc3  Â·  4Comments

StevenLi-DS picture StevenLi-DS  Â·  4Comments

adamjstewart picture adamjstewart  Â·  3Comments