20

I am trying to run Shapely on a new machine, and tried both installing it from source, using the installer on its webpage, and using pip install shapely. Every reference I try to make from the library except from shapely import * throws the error WindowsError: [Error 126] The specified module could not be found. Has anyone had a similar experience when trying to leverage Shapely, and figure out how to get it to function correctly?

Python Error Thrown:
WindowsError: [Error 126] The specified module could not be found

Environment:
Windows 7 64-bit
Python 2.7

  • The next line solved the problem in my case: conda install -c scitools/label/archive shapely – Vincenzo Oct 7 '18 at 16:53
29

You're doing your installation wrong.

Instead of

pip install shapely

go to https://pypi.org/project/Shapely/#built-distributions to see you can download Windows wheels at https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely

And On the second link, click on the file Shapely‑1.6.4.post1‑cp35‑cp35m‑win_amd64.whl

Shapely‑1.6.4 is the version of Shapely, cp35‑cp35m means the wheel is for Python 3.5, win_amd64 means it's for Windows with 64 bits architecture (you may choose another wheel depending on your Python version and Windows architecture)

Launch the install with the following and it will be OK after.

pip install Shapely‑1.6.4.post1‑cp35‑cp35m‑win_amd64.whl

Just as an information, "pip install shapely" works when you have the C compiler installed to build Geos dll and it's not the way it works on Windows.

  • Yeah, you are correct. Then I was not able to clean it all up correctly which was giving me the issue. Once I got it cleaned up, I ran just the installer and it started behaving again. – dkroy Jun 6 '13 at 20:57
  • There isn't a windows file at this link pypi.python.org/pypi/Shapely#downloads anymore :( – Wassadamo Sep 30 '18 at 23:31
  • I've made an update to the answer – ThomasG77 Oct 1 '18 at 14:51
2

Try using Conda-Forge

conda config --add channels conda-forge 
conda install shapely
1

Error 126 indicates that some dependent DLL can not be found. Presumably, this is because Shapely can not find GEOS.

Try using the install from pypi: LINK.

1

You can find Windows binaries at https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.