Error importing Polygon from shapely.geometry.polygon

In my Anaconda 2.2 64bit with Python 3.4.3, the following line works well:

import shapely

      

But the next line:

from shapely.geometry.polygon import Polygon

      

returns the following error:

OSError: [WinError 126] The specified module could not be found

      

What am I missing?

EDIT

I tried with iNotebook, idle.exe and Eclipse. They all use Anaconda (the only Python installation on my computer) and they all show the same error.

If I type from shapely.geometry import Polygon

in Eclipse, I click Polygon

, then click F3

, Eclipse can open the module C:\Anaconda3\Lib\site-packages\shapely\geometry\polygon.py

. So Eclipse can find it, but the execution fails.

EDIT 2

I just tried the same import on another computer with a similar configuration and it works. The "only" difference between these two computers is that you have Windows 7 (it works) and Windows 8 (it doesn't).

I have installed Anaconda and several packages on both computers following the same old checklist. Windows 8 computer can see the package from Eclipse, but cannot import it.

+3


source to share


3 answers


I had a similar problem and it was due to the fact that I did not install slender correctly (although this was on a Windows 7 machine, not Windows 8). For the initial installation, under which I was unable to import the submodule geometry

, I installed the slender command:

pip install shapely

      

However, after reading the documentation here in more detail, I saw that for Windows it is necessary to use an executable installer. This installer is a wheel file that should also run in pip. So, I removed the first version with:

pip uninstall shapely

      



Then I ran the installer through the wheels file like this:

pip install your/file/path/Shapely‑1.5.9‑cp27‑none‑win32.whl

      

Note that you must download a wheel that matches the specifications of the python version your package applies to. I have 32 bit ( win32

) python 2.7 ( p27

) so the above package was correct. Note that the 32 or 64 bit reference in the filename refers to the python version, not the windows version.

+5


source


Try the following:

from shapely.geometry import Polygon

      



The way the docs list it: http://toblerity.org/shapely/manual.html#polygons

+2


source


Don't use anything other than Python 3.7. Download it now!

Then go to PyCharm (which is what I'm using) and open it, then download the file for your specific version (from here https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely ) my Shapely -1.6. 4.post1-cp37-cp37m-win_amd64.whl (this is respectively version 3.7 (37) and Windows (64), as shown above)

Now with your recently downloaded file, copy and paste it where you are working in the PyCharm folder folder. For me it is: C: \ Users \ lewis \ PycharmProjects \ Project1 \ NewProject

Then you should see the file you just copied in PyCharm itself, as well as the location where you put it.

Now right click the file in PyCharm Shapely-1.6.4.post1-cp37-cp37m-win_amd64.whl and select OPEN IN TERMINAL, then type:

pip install Shapely-1.6.4.post1-cp37-cp37m-win_amd64.whl

      

It is worth saying "successfully".

Then go to the work area and enter:

from shapely.geometry import point

      

Run it. Now this should work for everyone!

Remember, this will ONLY allow you to import Shapely in this single environment. Therefore, you will have to copy the Shapely file to new folders if you use it elsewhere.

Tech Specs:
Remember I'm on Windows 10, Python interpreter version 37, PyCharm, Virutalenv environment type. Also make sure that in the settings you are indeed in the Python 37 interpreter and not in the conda environment.

0


source







All Articles