Python, GEOS and Shapely on Windows 64
Asked Answered
G

6

23

When trying to install Shapely on my Windows 64bit computer, I cannot get the GEOS library to work.

So far, I have run the OSGeo4W installer from which I installed GDAL (I believe the geos library is included in that package). After that, I checked and I have geos_c.dll on my C:\OSGeo4W\bin directory, but either I have missed some configuration steps or the library does not work.

I need Shapely to work, so I also ran pip install shapely after installing GDAL, and it apparently worked (although it could not find the C library for GEOS).

In my code, I can import Shapely, but when I try to use it, I get an error telling me "geos.dll" is not found.

Any help with this will be very appreciated. Thanks!

Groff answered 30/10, 2012 at 17:5 Comment(4)
What version of windows are you using?Andres
Maybe you could use an installer at the bottom of this page. That should include geos.Andres
Cool! Add this as an answer so I can accept it, please.Groff
In my case, I had to switch to a lower (3.10 to 3.9) Python versionAroid
M
20

Anaconda/Miniconda/Miniforge users should install Shapely (and dependencies) with:

conda install shapely

As of 2020, other Python users can install binary wheels from PyPI with pip:

pip install shapely

(you may need --upgrade to get at least version 1.7.0, when binary wheels were added.) Note that binary wheels are not available for Python 2 on Windows.


Another resource is Christoph Gohlke's Geospatial library wheels for Python on Windows releases on GitHub. Download the latest Shapely wheels from here, e.g., shapely-2.0.1-cp39-cp39-win_amd64.whl for 64-bit Python 3.9.

Meteoritics answered 25/7, 2013 at 5:2 Comment(1)
Make sure you install the version that matches your Python installation, NOT your OS. I made the mistake of installing the 64 bit shapely since I'm running 64 bit Windows, but my Python is 32 bit, and it gave me a similar "geos_c.dll" is not found.Hooknose
D
6

see my answer here https://mcmap.net/q/189917/-oserror-geos_c-could-not-be-found-when-installing-shapely-duplicate

on windows 10, python 3.6.5 64bit

  • install osgeo4w
  • add installed folder to path e.g. C:\OSGeo4W64\bin (must contain geos_c.dll)
  • restart command line
Downtrodden answered 31/5, 2018 at 12:13 Comment(0)
A
4

There is an version of Shapely available here that includes geos in the installer. Look at the bottom of the page.

Andres answered 25/11, 2012 at 16:58 Comment(2)
This version is from 2010-04-13, and was compiled for 32-bit Python 2.4, 2.5 and 2.6.Meteoritics
you can find newer versions by modifying the version number in the url. E.g. version 1.3.0 is from 2014 and works with python 2.7 and 3.3Boccioni
W
2

I tried the method of @jozef but failed even I imported the folder to the path.

A straightforward solution: add geos_c.dll, geos.dll to the library folder of your python environment. Then it works.

Whilom answered 4/8, 2020 at 1:34 Comment(2)
fastest fix, not sure that is se cleanest thoCrozier
You can download the dll at dll-files.com/geos_c.dll.htmlYang
S
1

I used the command below and it did work;

pip install Shapely==1.3.0

Smaragdine answered 6/12, 2019 at 16:39 Comment(0)
T
1

I've made it installing wheels for GDAL (and Fiona, in my case; might not be required) from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal Providing a path to the geos_c.dll didn't work. Neither putting them into venv/Lib.

Tieback answered 24/3, 2021 at 12:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.