JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
478 stars 88 forks source link

libpng error on MacOS #471

Closed Kunz-David closed 4 years ago

Kunz-David commented 4 years ago

Hello,

I was using PyPlot a while ago, but now when I came back to it now a get an error when running gcf():

julia> gcf()
Error showing value of type Figure:
ERROR: PyError ($(Expr(:escape, :(ccall(#= /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'ImportError'>
ImportError('dlopen(/Users/MrTrololord/.julia/conda/3/lib/python3.7/site-packages/matplotlib/_png.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libpng16.16.dylib\n  Referenced from: /Users/MrTrololord/.julia/conda/3/lib/python3.7/site-packages/matplotlib/_png.cpython-37m-darwin.so\n  Reason: Incompatible library version: _png.cpython-37m-darwin.so requires version 54.0.0 or later, but libpng16.16.37.0.dylib provides version 16.0.0')
  File "/Users/MrTrololord/.julia/conda/3/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 2065, in print_figure
    **kwargs)
  File "/Users/MrTrololord/.julia/conda/3/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line 501, in print_png
    from matplotlib import _png

Stacktrace:
 [1] pyerr_check at /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/exception.jl:60 [inlined]
 [2] pyerr_check at /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/exception.jl:64 [inlined]
 [3] _handle_error(::String) at /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/exception.jl:81
 [4] macro expansion at /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/exception.jl:95 [inlined]
 [5] #110 at /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:43 [inlined]
 [6] disable_sigint at ./c.jl:446 [inlined]
 [7] __pycall! at /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:42 [inlined]
 [8] _pycall!(::PyObject, ::PyObject, ::Tuple{IOContext{Base64.Base64EncodePipe}}, ::Int64, ::PyObject) at /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:29
 [9] _pycall!(::PyObject, ::PyObject, ::Tuple{IOContext{Base64.Base64EncodePipe}}, ::Base.Iterators.Pairs{Symbol,String,Tuple{Symbol,Symbol},NamedTuple{(:format, :bbox_inches),Tuple{String,String}}}) at /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:11
 [10] #_#117 at /Users/MrTrololord/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:86 [inlined]
 [11] Any at ./none:0 [inlined]
 [12] show(::IOContext{Base64.Base64EncodePipe}, ::MIME{Symbol("image/png")}, ::Figure) at /Users/MrTrololord/.julia/packages/PyPlot/4wzW1/src/PyPlot.jl:83
 [13] #base64encode#3(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::typeof(Base64.base64encode), ::Function, ::MIME{Symbol("image/png")}, ::Vararg{Any,N} where N) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/Base64/src/encode.jl:208
 [14] #base64encode at ./none:0 [inlined]
 [15] _binstringmime at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/Base64/src/Base64.jl:46 [inlined]
 [16] #stringmime#6(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::typeof(Base64.stringmime), ::MIME{Symbol("image/png")}, ::Figure) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/Base64/src/Base64.jl:43
 [17] (::Base64.var"#kw##stringmime")(::NamedTuple{(:context,),Tuple{IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}}}, ::typeof(Base64.stringmime), ::MIME{Symbol("image/png")}, ::Figure) at ./none:0
 [18] #stringmime#7(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::typeof(Base64.stringmime), ::String, ::Figure) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/Base64/src/Base64.jl:44
 [19] #stringmime at ./none:0 [inlined]
 [20] displayinplotpane(::Figure) at /Users/MrTrololord/.julia/packages/Atom/cYxbS/src/display/showdisplay.jl:83
 [21] display(::Atom.JunoDisplay, ::Figure) at /Users/MrTrololord/.julia/packages/Atom/cYxbS/src/display/showdisplay.jl:117
 [22] display(::Any) at ./multimedia.jl:323
 [23] #invokelatest#1 at ./essentials.jl:709 [inlined]
 [24] invokelatest at ./essentials.jl:708 [inlined]
 [25] print_response(::IO, ::Any, ::Bool, ::Bool, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:156
 [26] print_response(::REPL.AbstractREPL, ::Any, ::Bool, ::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:141
 [27] (::REPL.var"#do_respond#38"{Bool,Atom.var"#232#233",REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:719
 [28] #invokelatest#1 at ./essentials.jl:709 [inlined]
 [29] invokelatest at ./essentials.jl:708 [inlined]
 [30] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/LineEdit.jl:2306
 [31] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:1045
 [32] run_repl(::REPL.AbstractREPL, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/REPL/src/REPL.jl:201
 [33] (::Base.var"#770#772"{Bool,Bool,Bool,Bool})(::Module) at ./client.jl:382
 [34] #invokelatest#1 at ./essentials.jl:709 [inlined]
 [35] invokelatest at ./essentials.jl:708 [inlined]
 [36] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:366
 [37] exec_options(::Base.JLOptions) at ./client.jl:304
 [38] _start() at ./client.jl:460

Does anyone have a clue whats happening? I tried to install Conda.jl and ran Conda.update() which I thought would update the packages (as they recommend here), but it didn't help.

If it's any help I am on a mac an these are my versions:

julia> PyPlot.version
v"3.1.3"

julia> VERSION
v"1.3.1"
stevengj commented 4 years ago

Seems to be similar to #251, which was a conflict between the Conda and MacOS libpng libraries due to a broken qt5 backend. What is your PyPlot.backend?

Kunz-David commented 4 years ago

PyPlot.backend does this:

julia> PyPlot.backend
"Qt5Agg"
stevengj commented 4 years ago

I can't reproduce your problem. I'm on MacOS 10.14.6 and I'm using Python 3.7.4 installed by Conda.jl with the Qt5Agg backend.

Maybe try

using Conda
Conda.update()

to make sure your Anaconda installation is up to date? (You may need to add Conda at the pkg> prompt first.)

Kunz-David commented 4 years ago

Sorry for not coming back to this strait away, but I solved the problems without figuring out what the problem was. A simple using Conda; Conda.update() didn't help, so I ended up reinstalling everything (julia, and all the modules) which made it work. Thanks for the help!

samuela commented 3 years ago

I just came across this same issue with Julia 1.6.1, macOS 11.4, PyPlot v2.9.0, PyCall v1.92.3, Conda v1.5.2, PyPlot.backend = "Agg".

PyPlot.jl was working fine, then I added PyCall to my project and now it's broken. Not sure what exactly caused the breakage but that's the only relevant info I can think of.

samuela commented 3 years ago

Could we reopen? I really can't figure out a way around this

samuela commented 3 years ago

Deleting ~/.julia/conda, running ] build PyCall PyPlot Conda seems to make it work. Based on the logs, Conda reinstalls everything and somehow that fixes it.