6

This question is written in relation with the answer to Plotting a map using geopandas and matplotlib.

The main point is that installing (spatial) libraries such as Proj.4 or Contextily can be a confusing task under Windows, so that most of the time we are advised to directly

use the OSGeo4W software distribution.

An example of such an advise here.

A contrario, the task is rather easy with other operating systems.


The main idea is to provide interrogative users with a "lite" installation approach.

keepAlive
  • 6,369
  • 5
  • 24
  • 39

3 Answers3

13

Using Anaconda / conda

If you are using the Anaconda distribution or in general the conda package manager (which I recommend for installing the python geo stack), it should suffice to install contextily with:

conda install contextily --channel conda-forge

This will automatically install all python and C dependencies (proj.4, GDAL, ...)

This should work on all platforms (Windows, Linux, Mac).

joris
  • 133,120
  • 36
  • 247
  • 202
6

Windows

(Without any conda-like distribution)

After manually downloading the WHL files from Unofficial Windows Binaries for Python Extension Packages. Open an Administrator Command Prompt and type (illustrated on Python3.6 32bit):

pip3.6 install GDAL-2.3.3-cp36-cp36m-win32.whl && setx GDAL_VERSION "2.3.3"
pip3.6 install Fiona-1.8.4-cp36-cp36m-win32.whl
pip3.6 install geopandas-0.4.0-py2.py3-none-any.whl
pip3.6 install proj
pip3.6 install Shapely-1.6.4.post1-cp36-cp36m-win32.whl
pip3.6 install Cartopy-0.17.0-cp36-cp36m-win32.whl
pip3.6 install rasterio-1.0.13-cp36-cp36m-win32.whl
pip3.6 install contextily

(tested).

keepAlive
  • 6,369
  • 5
  • 24
  • 39
  • I would be glad to know the reason behind the downvote. Indeed, 1) the answer above works and 2) we may not want to use conda for many reasons, which I discourage incidentally. – keepAlive Nov 18 '20 at 08:22
1

Well from oficial install page with conda is :

conda install -c conda-forge contextily

Install geopandas and contextily