Shapely import error: No module named 'shapely'
Asked Answered
K

2

11

I've installed shapely with pip install shapely and importing it as from shapely.geometry import Point. I get this error:

  from shapely.geometry import Point
ModuleNotFoundError: No module named 'shapely'

I'm n MacOS High Sierra. All other installed python libraries work like a charm. I'm new to Python so forgive me in advance. I've read several similar questions (like this one) but none seemed to solve my problem.

Kinesiology answered 16/3, 2019 at 15:21 Comment(8)
Did you pip install it to a virtual environment? If so, you need to activate your virtual environment with source myvenv/bin/activate. If you haven't set up a virtual environment yet, you might have installed the module in the wrong directory. Make sure to install the module into the main directory of your project.Asleyaslope
Where did pip install it, and what is the value of sys.path?Oestrogen
You might find this SO question useful, as it provides resources on how to use a virtual environment. Virtual environments help you manage project dependencies and is especially helpful when you have multiple projects.Asleyaslope
@JohnGordon I installed it in my home directory /Library/Python/2.7/site-packages/. How do I check the value of my sys.path?Kinesiology
@JackMoody is there a way to install it globally for any projects? How do I activate the env?Kinesiology
@Kinesiology normally you don't want to install a module globally, because you will probably use multiple versions of the same module in between your projects. If you really do want to install it globally, you can use sudo as explained here. However, I would strongly encourage using a virtual environment if you plan on having multiple projects in the future.Asleyaslope
@JackMoody Thank you. I'll look into it.Kinesiology
import sys; print (sys.path)Oestrogen
E
12

Run the following command in activated virtualenv:

pip install shapely
Entrepreneur answered 12/10, 2020 at 14:48 Comment(0)
C
0

I tried this command and it was efficient.

conda install -c conda-forge shapely
Catacaustic answered 22/9, 2021 at 12:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.