# ImageMagick.jl and PyPlot.jl conflicting libpng

**URL:** <https://discourse.julialang.org/t/imagemagick-jl-and-pyplot-jl-conflicting-libpng/37139>\
**Category:** General Usage\
**Created:** [April 7, 2020, 4:02am UTC](https://discourse.julialang.org/t/imagemagick-jl-and-pyplot-jl-conflicting-libpng/37139 "2020-04-07T04:02:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Post date:** [April 7, 2020, 4:02am UTC](https://discourse.julialang.org/t/imagemagick-jl-and-pyplot-jl-conflicting-libpng/37139/1 "2020-04-07T04:02:07Z")

</div>

on my macOS machine, I can trigger this with

```julia
julia> import ImageMagick

julia> import PyCall; PyCall.pyimport("matplotlib")

```

gives

```julia
ImportError('dlopen(/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/ft2font.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libpng16.16.dylib\n Referenced from: /Users/goretkin/.julia/conda/3/lib/libfreetype.6.dylib\n Reason: Incompatible library version: libfreetype.6.dylib requires version 51.0.0 or later, but libpng16.16.37.0.dylib provides version 16.0.0')
  File "/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/ __init__.py", line 205, in <module>
    _check_versions()
  File "/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/ __init__.py", line 190, in _check_versions
    from . import ft2font

```

Swapping the import order succeeds.

`lsof` on the failing instance reveals

```julia
/Users/goretkin/.julia/artifacts/654881cff259b8d4bdb16253badceb0e7c2abef7/lib/libpng16.16.37.0.dylib

```

`lsof` on the succeeding instance reveals

```julia
/Users/goretkin/.julia/conda/3/lib/libpng16.16.dylib
/Users/goretkin/.julia/artifacts/654881cff259b8d4bdb16253badceb0e7c2abef7/lib/libpng16.16.37.0.dylib

```

This is about the end of my understanding of dynamic linking, but I thought I could post here so that someone could [help me to] open the appropriate issue.

---

<div class="post-metadata">

**Author:** ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Post date:** [April 7, 2020, 7:14am UTC](https://discourse.julialang.org/t/imagemagick-jl-and-pyplot-jl-conflicting-libpng/37139/2 "2020-04-07T07:14:48Z")

</div>

Now between `FFMPEG.jl` and `PyPlot.jl`, with opposite ordering:

```julia
julia> import PyCall; PyCall.pyimport("matplotlib")
PyObject <module 'matplotlib' from '/Users/goretkin/.julia/conda/3/lib/python3.7/site-packages/matplotlib/ __init__.py'>

julia> import FFMPEG
ERROR: InitError: could not load library "/Users/goretkin/.julia/artifacts/a6d3ce86d902a885e1e092882cb0ddb718aade03/lib/libass.9.dylib"
dlopen(/Users/goretkin/.julia/artifacts/a6d3ce86d902a885e1e092882cb0ddb718aade03/lib/libass.9.dylib, 1): Library not loaded: @rpath/libfreetype.6.dylib
  Referenced from: /Users/goretkin/.julia/artifacts/a6d3ce86d902a885e1e092882cb0ddb718aade03/lib/libass.9.dylib
  Reason: Incompatible library version: libass.9.dylib requires version 24.0.0 or later, but libfreetype.6.dylib provides version 23.0.0
Stacktrace:
 [1] dlopen(::String, ::UInt32; throw_error::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Libdl/src/Libdl.jl:109
 [2] dlopen at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Libdl/src/Libdl.jl:109 [inlined] (repeats 2 times)
 [3] __init__ () at /Users/goretkin/.julia/packages/libass_jll/Ty9Kb/src/wrappers/x86_64-apple-darwin14.jl:46
 [4] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:697
 [5] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:781
 [6] _tryrequire_from_serialized(::Base.PkgId, ::UInt64, ::String) at ./loading.jl:712
 [7] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:770
 [8] _require(::Base.PkgId) at ./loading.jl:1006
 [9] require(::Base.PkgId) at ./loading.jl:927
 [10] require(::Module, ::Symbol) at ./loading.jl:922
during initialization of module libass_jll

```

Importing `FFMPEG` first and then `matplotlib` does not cause the error, though it looks like there are errors downstream.

---

<div class="post-metadata">

**Author:** ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Post date:** [May 7, 2020, 5:08pm UTC](https://discourse.julialang.org/t/imagemagick-jl-and-pyplot-jl-conflicting-libpng/37139/3 "2020-05-07T17:08:55Z")

</div>

I have the same issue.

On Mac, with both

```julia
julia> using PyPlot

julia> using Plots

```

will error:

```julia
libass.9.dylib requires version 24.0.0 or later, but libfreetype.6.dylib provides version 23.0.0

```

---

<div class="post-metadata">

**Author:** ![wizofe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wizofe/32/13056_2.png) [@wizofe](https://discourse.julialang.org/u/wizofe)\
**Post date:** [July 4, 2020, 10:46am UTC](https://discourse.julialang.org/t/imagemagick-jl-and-pyplot-jl-conflicting-libpng/37139/4 "2020-07-04T10:46:25Z")

</div>

You need to load first `Plots` and the `PyPlot`. Say whaaaaat. Yes, it works 😃
