Stream: python-questions

Topic: matplotlib


view this post on Zulip David Bailey (Apr 18 2022 at 20:09):

Dumb question. I have a script that uses some matplotlib functions, but it cannot find these on cheyenne. Does anyone know what the issue with these lines would be:

    import matplotlib.pyplot as plt
    from mpl_toolkits.basemap import Basemap
    from mpl_toolkits.axes_grid1 import make_axes_locatable

Note that I tried both the ncar_pylib and the conda environment.

view this post on Zulip Kevin Paul (Apr 18 2022 at 20:11):

@David Bailey: When you say "on cheyenne," do you mean that you are running on the JupyterHub on Cheyenne? Or is this in a python script that you are running on a Cheyenne login or compute node directly?

view this post on Zulip David Bailey (Apr 18 2022 at 20:11):

I am running a python script on a cheyenne node directly.

view this post on Zulip Kevin Paul (Apr 18 2022 at 20:13):

Ok. Thanks! How are you setting up your python environment? (e.g., is it a module load npl or module load conda etc.)

view this post on Zulip David Bailey (Apr 18 2022 at 20:13):

I did the module load conda and then conda activate npl.

view this post on Zulip Kevin Paul (Apr 18 2022 at 20:13):

:+1:

view this post on Zulip Kevin Paul (Apr 18 2022 at 20:14):

Ok. After conda activate npl, can you do a conda list? What does it show?

view this post on Zulip David Bailey (Apr 18 2022 at 20:16):

matplotlib 3.5.1 py37h89c1867_0 conda-forge
matplotlib-base 3.5.1 py37h1058ff1_0 conda-forge
matplotlib-inline 0.1.3 pyhd8ed1ab_0 conda-forge

No mpl_toolkits.

view this post on Zulip Deepak Cherian (Apr 18 2022 at 20:17):

what about basemap?

view this post on Zulip David Bailey (Apr 18 2022 at 20:17):

No basemap either.

view this post on Zulip Kevin Paul (Apr 18 2022 at 20:20):

I'm not sure basemap is supported any more. The canonical replacement for basemap is cartopy. Is that the only "import error" that you are getting (namely, mpl_toolkit)?

view this post on Zulip David Bailey (Apr 18 2022 at 20:25):

Yes, that is the one that is missing. When you say "not supported" can I still use it? The script is not that old.

view this post on Zulip Kevin Paul (Apr 18 2022 at 20:26):

I think you can still use it. But the NPL conda environment is supported by the CISL CSG folks, and you would need to ask them to install basemap in the NPL conda environment.

view this post on Zulip David Bailey (Apr 18 2022 at 20:27):

Got it. I suppose I could convert to cartopy. Can you point me to a good quick start guide?

view this post on Zulip Kevin Paul (Apr 18 2022 at 20:53):

Ryan Abernathey at LDEO has a nice tutorial on cartopy here:

https://rabernat.github.io/research_computing_2018/maps-with-cartopy.html

And he even mentions at the top that Basemap is "going away."

view this post on Zulip David Bailey (Apr 18 2022 at 21:14):

Great. I was able to do pip install basemap and get it working. So, that at least gives me a solution short-term.

view this post on Zulip Drew Camron (Apr 19 2022 at 16:51):

Previous maintainers of basemap had indeed stepped away and pointed people to Cartopy, intending for a "final" release in 2020 with Python 2 EOL. I just now discovered that partial maintenance has been resumed by volunteers, and they seem to have chosen to remove said notices about deprecation and cut multiple new releases for Windows/Linux in just the past few months. I guess there's still some love for basemap!

view this post on Zulip Kevin Paul (Apr 19 2022 at 16:53):

Never underestimate open source, I guess! :smile: Thanks for that find, @Drew Camron!


Last updated: May 16 2025 at 17:14 UTC