0

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
3
  • 1
    try to open a terminal and then a python console. Then, import matplotlib in that python console. If you get no error, it means your IDE is not able to recognise it. Sometimes a simple restart of your IDE solves the problem. Sometimes, you need to modify python path in your IDE. Commented Jul 7, 2016 at 19:21
  • It looks like you have an older version of libpng. Try an older version of matplotlib (or update libpng) and see if it solves the problem. Anaconda comes preinstalled with matplotlib, so this should work out of the box. Commented Jul 7, 2016 at 19:26
  • thanks for your help. I took the crude approach and simply re-installed the latest version of anaconda, and the problem seems solved. Commented Jul 8, 2016 at 0:19

3 Answers 3

4

For future reference:

brew uninstall libpng
conda uninstall matplotlib
conda install matplotlib

Basically let conda decide which libpng version to use.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

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!

2 Comments

thanks! I simply re-installed anaconda from the continuum site -- seems ok now.
That is awesome! Happy to help, and welcome to Stack Overflow! If this answer or any other one solved your issue, please mark it as accepted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.