import matplotlib.pyplot gives ImportError: dlopen(…) Library not loaded libpng15.15.dylib

后端 未结 3 1505
孤街浪徒
孤街浪徒 2020-12-13 10:24

I am aware that this exact same question has been asked before. I did follow the instructions given in the answer there, and it didn\'t solve my problem (and I don\'t have e

相关标签:
3条回答
  • 2020-12-13 10:37

    I ran into this problem as well. I updated my Anaconda-Navigator and the next time I opened a project with matplotlib.pyplot, I ran into a similar problem. What worked for me was:

    conda install libpng
    
    0 讨论(0)
  • 2020-12-13 10:40

    Some python packages link dynamically against native c libraries. After an update of one of those libraries, links can break and give you weird error messages about missing dynamic libraries, as seen in the error message in the question.

    Basically, after an update of a native library sometimes you also have to rebuild python packages (here matplotlib).

    The above statement is true in general. If you are using conda as your python distribution things are usually less complicated:

    For extension packages conda also maintains required c libraries. As long as you use only conda install and conda update for installing those packages you should not run into these issues.

    For numpy, scipy, matplotlib and many more I would suggest to try conda search <library name> first to see if there's a conda recipe that matches your needs. For most users conda install <library name> will be a better option than pip install.

    To make sure that only conda's version is installed you can do

    conda remove matplotlib
    pip uninstall matplotlib
    conda install matplotlib
    

    Afterwards this issue should not appear anymore.

    0 讨论(0)
  • 2020-12-13 10:44

    I had this problem, but it was because I had set

    export DYLD_LIBRARY_PATH="/Users/charlesmartin14/anaconda/lib":$DYLD_LIBRARY_PATH

    removing this setting and restarting the shell fixed it

    0 讨论(0)
提交回复
热议问题