Matplotlib import error

I am trying to run fastai on a local machine (Mac notebook), and I get an error with Lesson 5 that reads…

—> 46 from matplotlib import (
47 backend_tools as tools, cbook, colors, textpath, tight_bbox, transforms,
48 widgets, get_backend, is_interactive, rcParams)

ImportError: cannot import name ‘get_backend’

I am using Anaconda and have a fastai environment (also a fastai-cpu environment, since Apple has not released an updated CUDA driver for 5 months(!!!)). My python environment works in general, except for this error. I’m pretty new to Python and environments and haven’t been able to figure out how to fix it.

Thanks!
John

Answering my own question; it turned out to be my confusion over Python environments. Some of the packages that fastai was looking for were in the fastai-cpu environment, not the fastai environment. I discovered that by dumping the contents of each environment into a .yml file and then comparing them-- a handy trick since I wanted to see the contents side by side:
conda activate fastai-cpu
conda env export > fastai-cpu_env.yml
…for each environment. There’s probably a simpler way.
I was also using Jupyter Lab, which I really love (it’s a much-improved alpha version of Jupyter Notebooks with a lot of really nice features – see this intro and I had installed that in my (base) conda environment, without really realizing that. So to correct the problem, I did this:

  1. Added Jupyter Lab to the fastai-cpu environment:
    conda install -n fastai-cpu -c conda-forge jupyterlab

  2. Now whenever I start it up, I just have to remember to switch to fastai-cpu:
    conda activate fastai-cpu
    jupyter lab
    …and it all works.