2

I am beginner in Linux. I have a problem to use Shapely 1.6.4 post2... I installed shapely by this command:

$ pip install shapely

and it worked good

Collecting shapely
  Using cached https://files.pythonhosted.org/packages/81/d1/b8e1b089a8ddd6df74be583d70373eac55c725c6197c115efbd3c3e1509f/Shapely-1.6.4.post2-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: shapely
Successfully installed shapely-1.6.4.post2

but when i want to import shapely...

$ python chp1.py
Traceback (most recent call last):
File "chp1.py", line 3, in <module>
from shapely.geometry import Point
ModuleNotFoundError: No module named 'shapely'

I use python 3.6.7

Could you explain the problem?

4
  • 1
    Are you sure that your pip and python executables are using the same Python version? "cp27" suggests pip installed it for Python 2.7 rather. Are you using any helpers or environments (conda, pipenv, venv etc)? Dec 11, 2018 at 12:04
  • I would recommend using Anaconda for the installations. Conda will allow you to create an isolated environment to do the installs. Even better, it allows you to control the version of Python you use within that environment.
    – Aaron
    Dec 11, 2018 at 13:08
  • bugmenot123 - Default setting is python 3.6.7 Sorry what is exactly "cp27"? :/ I didn't use any environments...I m going to check that better!! I m going to try Conda first!
    – Meeko67
    Dec 11, 2018 at 13:33
  • Thank you very much for your help! I used pip3 and it works now. I m going to keep installing conda because i should be useful anyway!
    – Meeko67
    Dec 11, 2018 at 14:28

1 Answer 1

3

If you are using python 3.6.7, for installing shapely you need to do:

pip3 install shapely

If you got an error and you use Debian or Debian derivatives distros you need to do first:

apt-get install python3-pip

as superuser (for other Linux distros you need to use equivalent command).

By default:

pip install shapely

install shapely for your python 2.7.x version.

2
  • Installing conda in linux, i tried your option "pip3" at the same time and its works!!! Actually, i tried your second command too but finally nothing happened, but pip3 is ok! Should i use everytime pip3 if i use python 3.X?
    – Meeko67
    Dec 11, 2018 at 14:24
  • Yes, you should use pip3. If you believe that your question was answered, please mark as accepted.
    – xunilk
    Dec 11, 2018 at 21:25

Your Answer

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

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