Building an environment for matplotlib + cartopy on Mac

Introduction

It is common to use matplotlib and cartopy to visualize meteorological data with a map using Python. The procedure for building the environment for that with Anaconda (Miniconda) is described below. The OS version you have is macOS Catalina 10.15.7.

Installation of Anaconda (Miniconda)

Anaconda is a Python distribution that allows you to manage packages and create virtual environments. You can do the same thing with pyenv and pip, but I'll use this because it's convenient because you can install dependent programs at the same time.

Miniconda is the minimum configuration version of Anaconda. Since there are few packages installed at the beginning and there is an advantage that it does not take up disk space, we will introduce this.

#Download installer
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh

#Install interactively
bash Miniconda3-latest-MacOSX-x86_64.sh

You can refer to other articles for how to use it, but you can use the conda command to manage packages for each virtual environment. If the prompt says something like (base) $, it means you are in the anaconda virtual environment called base. You can install the package in the base environment, but here we will create a new environment called cartopy-env.

conda create -n cartopy-env python=3.9

Just creating a virtual environment with conda create does not include python, so make sure to install Python by specifying the version. Here, I specified the latest version 3.9 at the time of writing.

Hit conda activate to switch the virtual environment.

conda activate cartopy-env

It's OK if the prompt shows something like (cartopy-env) $.

Package installation

Next, install the required Python packages. For example, to install numpy for scientific calculations, use the following command.

conda install -c conda-forge numpy

Since the same package is provided by multiple repositories in conda, the -c option specifies which repository to install from (here, conda-forge). You can search for what packages are available at https://anaconda.org/. Basically, you can choose the conda-forge repository.

Now let's install the other necessary items. You can specify multiple package names separated by spaces.

conda install -c conda-forge scipy netcdf4 matplotlib cartopy

You can check the version of the installed package with conda list. Here's a rough description of the major package versions installed in your environment.

--numpy (1.19.4): Library for scientific computing --scipy (1.5.3): A library for scientific computing, including functions not found in numpy. --netcdf4 (1.5.4): Required to read and write netCDF format files. Recently, it seems that xarray is sometimes used as an equivalent. --matplotlib (3.3.3): Required for drawing diagrams --cartopy (0.18.0): Required to draw a map with matplotlib

That's all for the explanation.

Recommended Posts

Building an environment for matplotlib + cartopy on Mac
Building an environment for "Tello_Video" on Raspbian
Building an environment for "Tello_Video" on Windows
Building an environment for executing Python scripts (for mac)
[Definitive Edition] Building an environment for learning "machine learning" using Python on Mac
Building a Python environment on Mac
Django Crispy Tutorial (Environment Building on Mac)
[Mac] Building a virtual environment for Python
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
Building an Anaconda environment for Python with pyenv
Various commands for building an environment with Apache
Try building an environment for MayaPython with VisualStudioCode
How to build an environment for using multiple versions of Python on Mac
Build a local development environment for Laravel6.X on Mac
Building an environment for natural language processing with Python
Create an environment for MkDocs on Amazon Linux (attempted)
Procedure for building a CDK environment on Windows (Python)
Building an environment for displaying organic compounds using RDKit
Building a Python environment for programming beginners (Mac OS)
Pyramid + mongodb environment on Mac
Python environment construction For Mac
Ansible environment construction For Mac
[Python] Building an environment for competitive programming with Atom (input () can be used!) [Mac]
Build an environment for machine learning using Python on MacOSX
Let's get started with Python ~ Building an environment on Windows 10 ~
Building a Python environment on a Mac and using Jupyter lab
Building an environment to execute python programs on AWS EC2
Create a virtual environment for python on mac [Very easy]
Building an auto-sklearn environment that semi-automates machine learning (Mac & Docker)
Error when building mac python environment
Building a Python environment on Ubuntu
Steps to install matplotlib on Mac
Create a Python environment on Mac (2017/4)
Django beginners tried building an environment
Python environment construction memo on Mac
Environment construction of python3.8 on mac
Python3 TensorFlow for Mac environment construction
Created an environment for Anaconda & Jupyter
Building an environment to run ChainerMN on a GPU instance on AWS
Anyone can understand how to build an initial environment for Python on Mac September 2016 (pyenv + virutalenv)
Things to watch out for when creating a Python environment on a Mac
Build an environment for Blender built-in Python
I easily built an operating environment for Python3 + Tornado on AWS EC2.
Programming environment for beginners made on Windows
Create a python environment on your Mac
Note on building your own Miniconda environment
Building a LaTeX environment on Chrome OS
Notes on building Python and pyenv on Mac
I installed Kivy on a Mac environment
Build Python environment with Anaconda on Mac
About Japanese fonts of matplotlib (for Mac)
Prepare the development environment for keyhac for Mac
Create an OpenCV3 + python3 environment on OSX
Building a conda environment for ROS users
Building a Python development environment for AI development
Notes from installing Homebrew to building an Anaconda environment for Python with pyenv
A story about building an IDE environment with WinPython on an old Windows OS.
I've built an environment to try using TensorFlow on mac, so my memo
Selenium + WebDriver (Chrome) + Python | Building environment for scraping
Put Python's numerical calculation environment Anaconda on mac (2)
Put Python's numerical calculation environment Anaconda on mac