Mac Instructions

This page describes how to set up a python environment required to use `geopandas`, which is a python library for geospatial data processing

First, the gdal library must be installed. On a mac, this requires brew installing in the base environment as in:

brew install gdal

Then, it is helpful to utilize pip-tools for compiling and pinning version requirements. pip-tools can be installed with pip as in:

pip install pip-tools

Then, a file listing the basic python package requirements can be created. An example file is:

requirements.in
geopandas
pandas
folium
jupyter
matplotlib
mapclassify

Then, pip-tools can be used to "compile" the requirements into specific pinned versions of all packages and their dependencies, as in:

pip-compile requirements.in

This will create a file called requirements.txt in the same folder where the above command is run. Attached is an example requirements.txt file

Example requirements.txt file

Next, a virtual environment is one possible way to manage package versions in a contained manner. virtualenv is a helpful way to do this and can be installed as in:

Next, a virtual environment, called env in the below, can be created as in:

Now the python environment that can run geopandas can be used in python scripts or jupyter notebooks. A jupyter notebook can be started as in:

Then geopandas can be used for the various geospatial functions in the code in the other sections in a notebook.

Last updated