Howto: Install Python for geospatial applications

Installing Python 3.7 with Anaconda for Windows

  • Uninstall any remaining Python Anaconda installations via Start > “Apps & features”.
  • Download the Python 3.7 - 64-Bit Graphical Installer from the Anaconda website.
  • Install it using the default options, except select “C:\Anaconda3” as the installation path, and check “Add Anaconda to Path”. By default Anaconda Python would be installed to Windows AppData, setting the installation path to a folder on the “C:” drive is just for convenience when configuring paths and environments.
  • Open the environment variables (just search in the Windows start menu. If you are not admin by default on your system, use right-click > Open as administrator). In the bottom section under “System variables” check that the “Path” variable includes the following paths. If not, add them by using the “New” button.
  • C:\Anaconda3
  • C:\Anaconda3\Scripts
  • Open the command-line via Start > “cmd” and run the following commands. Explanations and potential errors explained below respectively.
conda update -n base conda
conda config --add channels conda-forge
conda update --all

Creating a virtual environment

A virtual environment acts as a “container” for your Python installation. If you are just starting out or don’t need to manage multiple projects that could require different dependencies, using virtual environments often seems unnecessary when you could just use the base installation. I personally still recommend to use an environment for another reason: Because you can clone/backup your working environment, you will have a lot less frustration when something breaks your Python installation.

conda create --name geo_py37 python=3.7
activate geo_py37

Installing GDAL

I have seen quite a lot of people getting frustrated by problems stemming from version and dependency issues related to GDAL & rasterio when installing other libraries at the same time. Thus, just to be save, we will start with these two.

conda install gdal
conda install rasterio
activate geo_py37
python
import gdal
import rasterio
exit()

Installing the rest of the packages

Install all other packages using one long command:

activate geo_py37
conda install numpy pandas geopandas scikit-learn jupyterlab matplotlib seaborn xarray rasterstats tqdm pytest sqlalchemy scikit-image scipy pysal beautifulsoup4 boto3 cython statsmodels future graphviz pylint mlxtend line_profiler nodejs sphinx nbsphinx
pip install sentinelsat mercantile
pip install sentinelsat mercantile --trusted-host pypi.org --trusted-host files.pythonhosted.org

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store