I already use another library "shapefile", which was easy to import. However I just installed shapely 1.3.3 for windows (which still has an installer) and cannot import it. I tried it the same way as with the other library (import shapely) after the installation, but it only throws the error:

ImportError: No module named shapely

Edit: I run Python-2.7.9 and have GEOS installed. If I try "import shapely" I get the error "No module named shapely" and if I don't do it, I get this:

print Point.geom_type

AttributeError: 'tuple' object has no attribute 'geom_type'

Can somebody resolve this? It should be a legit command. I do not understand what could be wrong.

Edit: It seems like shapely is not recognized by Python, eventhough it definitely is installed. I tried using another version of Shapely and got the same result. I really need a Shapely function to continue working on a work project but cannot figure out why it doesn't work. I also tried installing it with pip, which wasn't of any use as well.

  • 1
    "eventhough it definitely is installed" -> where ? (you can download the version 1.5.17 for Windows from Unofficial Windows Binaries for Python Extension Packages)
    – gene
    Commented Mar 20, 2017 at 12:31
  • I already downloaded that as well and installed it in the same directory as my python version by using pip and the console.
    – Homerun_
    Commented Mar 20, 2017 at 13:23
  • Did you install it somewhere other than the default location?
    – Ali
    Commented Mar 20, 2017 at 15:26
  • Well it recoginzes compatible versions and I chose the folder containing the version I am working with. In a way there was no default location.
    – Homerun_
    Commented Mar 20, 2017 at 15:30

1 Answer 1


You can check where Python is looking for modules using:

import sys

for s in sys.path:
    print s

This will generally be a list of directories. If your Shapely module was not installed to one of these then Python wont be able to "see" it.

In this case you will either have to re-install it to one of the shown directories or make its location known to Python. You can do this in the code itself:

import sys

# Add shapely's parent directory to the list to be searched

# Now import Shapely
import shapely

You will have to include the above within each Python file in which you import Shapely. For a more permanent solution you can set the PYTHONPATH environment variable with search paths you want to always include. For more information check out the sys module, particularly sys.path.

  • Thank you, the shapely folder was not in the list of searched directories. But now it still cannot find Shapely. Like I said, there is no file shapely.py or anything like that. However C:\Python279\Lib\site-packages\shapely has a lot of .py files, just not shapely.py. Maybe I if I figure out which of these has the function I need and only import that one?
    – Homerun_
    Commented Mar 21, 2017 at 9:23
  • @Homerun_ It's the shapefly folder itself that is the package, so make sure its parent, C:\Python279\Lib\site-packages, is included in your sys.path.
    – Ali
    Commented Mar 21, 2017 at 9:28
  • Oh, now I just feel stupid, haha. I changed that, but now the error just changed. Before I could import e.g. "ops" from the shapefile directory (import ops) which had the problem that it relied on shapely.geometry which could not be found. Now I changed it as you adviced and neither import ops nor import shapely.ops works anymore. Isn't that weird? What is going on?
    – Homerun_
    Commented Mar 21, 2017 at 9:55
  • It has to do with how modules are accessed inside of packages. You can still import your ops module but you will now have to use: from shapely import ops.
    – Ali
    Commented Mar 21, 2017 at 9:58
  • from shapely import ops throws the error 'ImportError: No module named shapely'.
    – Homerun_
    Commented Mar 21, 2017 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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