In this tutorial we will discuss how to install the Shapely Library for Python. The Shapely library is used for the manipulation and analysis of planar geometric objects. It is built upon on the widely used GEOS and JTS libraries, with which it also shares quite a bit in common (concept wise).
As Shapely is not included in the Python Standard Library, we need to download and install it separately. There are several methods of doing so, depending on your Operating system and Coding environment. Lets discuss a few of these.
Installing Shapely in Python
The most common method of installing Shapely, that works across various popular OS’s, such as Linux and Windows is by using “pip”. The command for it is shown below.
pip install shapely
The most recent version of Shapely (1.8), requires you to have a Python version of 3.6 or above. If you need to be working with an older version of Python, then simply install an older version of Shapely that is compatible (though you might be missing some features, depending on how back you go)
pip install shapely==1.8.0
Linux users
Here is a command that Linux users can use, who do not or cannot use pip.
sudo apt-get install python3-shapely
for Python 2.x users, you can do the following:
sudo apt-get install python-shapely
For conda users
The first line is an extra precaution because sometimes the second line by itself is not enough.
conda config --add channels conda-forge
conda install shapely
Now that you are done with installation, head over to our Shapely tutorial to learn how to use it!
This marks the end of the How to Install Shapley for Python Tutorial. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the tutorial content can be asked in the comments section below.