# Mac Instructions

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

{% code overflow="wrap" lineNumbers="true" %}

```bash
brew install gdal
```

{% endcode %}

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

{% code lineNumbers="true" %}

```bash
pip install pip-tools
```

{% endcode %}

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

{% code title="requirements.in" overflow="wrap" lineNumbers="true" %}

```bash
geopandas
pandas
folium
jupyter
matplotlib
mapclassify
```

{% endcode %}

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

{% code overflow="wrap" lineNumbers="true" %}

```bash
pip-compile requirements.in
```

{% endcode %}

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

{% file src="<https://3212476574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Foh9c3w7RI0Bl5tVCxcyz%2Fuploads%2FhS2HM3yJzSF1gCGIiG4f%2Frequirements_doc.txt?alt=media&token=407d17d1-4620-4835-ae30-e6e24a1520ef>" %}
Example `requirements.txt` file
{% endfile %}

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:

{% code overflow="wrap" lineNumbers="true" %}

```bash
pip install virtualenv
```

{% endcode %}

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

{% code overflow="wrap" lineNumbers="true" %}

```bash
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
```

{% endcode %}

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:

{% code overflow="wrap" lineNumbers="true" %}

```bash
python -m jupyter lab
```

{% endcode %}

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