user3161399
user3161399

Reputation: 253

error importing python matplotlib

I am attempting to import a matplotlib function (Mac OS 10.11.4) using Anaconda and python 3.4

I successfuly installed the latest matplotlib using conda install -c conda-forge matplotlib=1.5.2

And in the program, when I used: import matplotlib.pyplot as plt

I got this error message:

File "/Users/myname/anaconda/lib/python3.4/site-packages/matplotlib/mathtext.py", line 60, in <module>
    import matplotlib._png as _png

ImportError: dlopen(/Users/myname/anaconda/lib/python3.4/site-packages/matplotlib/_png.so, 2): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: /Users/myname/anaconda/lib/python3.4/site-packages/matplotlib/_png.so
  Reason: Incompatible library version: _png.so requires version 40.0.0 or later, but libpng16.16.dylib provides version 38.0.0

Upvotes: 0

Views: 1514

Answers (3)

lacfo
lacfo

Reputation: 79

I just use conda uninstall matplotlib and then conda install matplotlib to solve this problem.

Upvotes: 1

Sean
Sean

Reputation: 394

For future reference:

brew uninstall libpng
conda uninstall matplotlib
conda install matplotlib

Basically let conda decide which libpng version to use.

Upvotes: 4

Jaxian
Jaxian

Reputation: 1146

Solution: For the least intrusive solution I would simply update libpng.

Additional: You should also make sure you only installed Anaconda from https://www.continuum.io and not Anaconda PLUS Python from python.org. I just want to make sure that isn't causing conflicts because a lot of people make that mistake.

good luck, and happy programming!

Upvotes: 0

Related Questions