Installing Python on Mac M1
The new Mac M1 processors are pretty cool, and are enough to convert this veteran Linux user to Mac. Since Mac M1, M2, etc. are all ARM-based there are some differences to be aware of when installing your Python environment. Some instructions I have seen have recommended installing the x86 (Intel) packages, but there is a performance penalty when x86 programs are interpreted by Rosetta2 to work on the M1 Macs. Instead, these instructions will get you a fully functioning scientific Python environment working natively on M1 architecture.
We will use conda
and brew
to install packages:
- Download and install the latest pygplates version corresponding to your system architecture (Mac M1 ARM) and take note of the installation directory and python path.
- Install conda (we recommend miniforge) and create a new environment e.g.
conda create -n pygplates python=3.9
. - Activate your new python environment with
conda activate pygplates
- Some packages require additional dependencies such as compilers and mapping libraries outside of conda (I’m looking at you GDAL!) To do this install homebrew, then run
brew install qt5 gcc gdal cgal
. - Then you should be able to install your Python packages:
conda install numpy scipy netcdf4 geopandas pandas cartopy jupyter rasterio conda-build
- Link to your pygplates installation using the python path you wrote down at step 1. In my case
conda develop /Users/ben/Downloads/pygplates_0.35.0_py39_Darwin-arm64
- Install any additional dependendies (that don’t have a conda forumla) using pip:
pip install PlateTectonicTools
.
Now you should have a working pyGPlates installation with additional dependencies required to for scientific Python applications! Additional details on installing pyGPlates
can be found here. A conda package for pyGPlates is being developed.
A summary of all the commands are below. Happy coding!
conda create -n pygplates python=3.9
conda activate pygplates
brew install qt5 gcc gdal cgal
conda install numpy scipy netcdf4 geopandas pandas cartopy jupyter rasterio conda-build
conda develop /Users/ben/Downloads/pygplates_0.35.0_py39_Darwin-arm64
pip install PlateTectonicTools