question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: Code not running after installingPyGEOS

See original GitHub issue
  • I have checked that this issue has not already been reported.

  • 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.


Code Sample, a copy-pastable example

world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
world.head()

Problem description

I have installed PyGEOS because my process is slow and I read this: Using the optional PyGEOS dependency. For a code that was working without PyGEOS, I get now a “UserWarning: The Shapely GEOS version (3.4.3-CAPI-1.8.3 r4285) is incompatible with the GEOS version PyGEOS was compiled with (3.8.1-CAPI-1.13.3). Conversions between both will be slow. shapely_geos_version, geos_capi_version_string” and “Process finished with exit code -1073741819 (0xC0000005)”.

Expected Output

The code should simply run faster than without PyGEOS, ideally. The output should be:

0     1  ...  MULTIPOLYGON (((2546732.494 1193708.955, 25465...
1     2  ...  MULTIPOLYGON (((2549140.721 1178014.176, 25493...
2     3  ...  MULTIPOLYGON (((2595270.119 1251478.978, 25942...
3     4  ...  POLYGON ((2692430.313 1281173.385, 2692994.572...
4     5  ...  MULTIPOLYGON (((2686913.929 1272389.921, 26868...
5     6  ...  POLYGON ((2662038.335 1237690.711, 2662272.506...
6     7  ...  POLYGON ((2716299.544 1165466.590, 2716755.976...

Output of geopandas.show_versions()

Without PyGEOS:

SYSTEM INFO
-----------
python     : 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)]
executable : C:\...\python.exe
machine    : Windows-10-10.0.17763-SP0

GEOS, GDAL, PROJ INFO
---------------------
GEOS       : None
GEOS lib   : None
GDAL       : 3.1.2
GDAL data dir: None
PROJ       : 7.0.1
PROJ data dir: C:\...\lib\site-packages\pyproj\proj_dir\share\proj

PYTHON DEPENDENCIES
-------------------
geopandas  : 0.8.1
pandas     : 1.0.1
fiona      : 1.8.16
numpy      : 1.18.2
shapely    : 1.7.1
rtree      : 0.9.4
pyproj     : 2.6.1.post1
matplotlib : 3.1.1
mapclassify: None
geopy      : None
psycopg2   : None
geoalchemy2: None
pyarrow    : None
None

With PyGEOS:

SYSTEM INFO
-----------
python     : 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)]
executable : C:\...\python.exe
machine    : Windows-10-10.0.17763-SP0

GEOS, GDAL, PROJ INFO
---------------------
GEOS       : None
GEOS lib   : None
GDAL       : 3.1.2
GDAL data dir: None
PROJ       : 7.0.1
PROJ data dir: C:\...\lib\site-packages\pyproj\proj_dir\share\proj

PYTHON DEPENDENCIES
-------------------
geopandas  : 0.8.1
pandas     : 1.1.1
fiona      : 1.8.16
numpy      : 1.19.1
shapely    : 1.7.1
rtree      : 0.9.4
pyproj     : 2.6.1.post1
matplotlib : None
mapclassify: None
geopy      : None
psycopg2   : None
geoalchemy2: None
pyarrow    : None
None

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
antonindanaletcommented, Oct 9, 2020

Woohoo, it works when adding shapely.speedups.disable() with the minimal example! It also works with my larger project, and really really faster 👍

Thank you very much! Great and super fast answer.

2reactions
jorisvandenbosschecommented, Oct 9, 2020

So then it might actually be a problem with the Shapely installation, and not with the use of pygeos or not. The Shapely speedup cython module is built against GEOS 3.8, but for some reason it is finding GEOS 3.4 in your environment.

Two things to try. Can you see if disabling shapely’s speed-ups solve it?

import shapely
shapely.speedups.disable()

(and then running the code again)

Alternatively, a pure-Shapely reproducer migth be something like

from shapely.geometry import Polygon
Polygon([[1, 0], [1, 1], [0, 1], [0, 0], [1, 0]])
Read more comments on GitHub >

github_iconTop Results From Across the Web

I am not able to read .shp files anymore after installing pygeos ...
But when I installed pygeos for other work, problems started and i get this error when running exactly those same lines. Here is...
Read more >
Changelog — pygeos documentation
Unittests are now included in the pygeos distribution. Run them by 1) installing pytest (or pygeos[test] ) and 2) invoking pytest --pyargs ...
Read more >
pygeos 0.3 - PyPI
This is a C/Python library that wraps geometry functions in GEOS in numpy ufuncs. This project is still in a mock-up phase: the...
Read more >
pip install geopandas error | The Search Engine You Control
First try to conda install -c conda-forge geopandas . If it doesn't work, do the following steps: Download wheels for your Python version...
Read more >
Error while using sjoin in GeoPandas - GIS Stack Exchange
Solution: First: sudo apt install libspatialindex-dev. Then: sudo pip3 install rtree.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found