Matplotlib v3.1.3 upgrade, pyplot not working

MacOS, using python3.7, I just updated to matplotlib v3.1.3. Importing matplotlib.pyplot gives me the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/pyplot.py", line 32, in <module>
    import matplotlib.colorbar
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/colorbar.py", line 27, in <module>
    import matplotlib.artist as martist
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/artist.py", line 13, in <module>
    from .path import Path
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/path.py", line 17, in <module>
    from . import _path, cbook, rcParams
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/_path.cpython-37m-darwin.so, 2): Symbol not found: _MPL_matplotlib__image_ARRAY_API
  Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/_path.cpython-37m-darwin.so
  Expected in: flat namespace
 in /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/_path.cpython-37m-darwin.so

I’ve never encountered something like this before; not sure what _MPL_matplotlib__image_ARRAY_API is.

Any suggestions would be greatly appreciated! Thanks!

Suggest using conda.

That suggests that the wheels we uploaded are not good, which is something we definitly need to fix. As part of the build process we do run the tests from the wheel so this may not manifest on all machines.

How exactly did you do the upgrade?

While conda does simplify package management in many cases, the only binaries we publish as a project is the wheels so they need to be corect.

Thanks for the replies. I install and upgrade my Python packages using MacPorts. I periodically upgrade all MacPorts packages via:
sudo port upgrade outdated
which in this case a couple days ago grabbed the latest stable release of Matplotlib. I tried uninstalling and reinstalling all my MacPorts packages, but found the same problem.

Now here is the even bigger mystery: I have a second computer that I try to maintain as identical as the first (same platform, same OS version, etc.), and did a recent upgrade as well, but the second Matplotlib installation does NOT give me this error. I will do an installation-wide diff comparison. Naively it seems to me that maybe my first machine is simply missing a required .so file somewhere in the installation, is that what you suspect as well?

I know a lot of people like Conda. I tried it out a few years ago and found MacPorts to be simpler to use and less buggy, though I realize I’m in the minority with that opinion.

If you installed the binaries through macports, this probably should be reported to the macports maintainers.

Matplotlib has a number of c-extensions (some are for performance (like the the path (as in (x, y, code) triples, not file system path) and others are to bridge out to c++ libraries (ex Agg). In either case, the packager (us for the wheels, anacnoda, conda-forge, macports, brew, the linux distros, …) are responsible for building the extension and making sure it plays nice with the rest of the binaries that they ship.

It is very easy for packaging to go sideways, and often not worth tracking down exactly why. If the other computer works through more-or-less the same process I would try re-running the upgrade (they may have fixed the binaries between you doing the two upgrades?) and if that does not fix it, doing the “have you tried turning it off and on again” of uninstalling Matplotlib and re-installing.

The issue was indeed resolved via MacPorts. For completeness, the solution at this link solved my problem (use_parallel_build no in port file and rebuild matplotlib from source).

1 Like