# Warning "Error requiring PyPlot from Plots" in compiled julia program

**URL:** <https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857>\
**Category:** New to Julia\
**Tags:** question, pyplot, package-compiler\
**Created:** [November 7, 2022, 6:58am UTC](https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857 "2022-11-07T06:58:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![clarakoehne](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@clarakoehne](https://discourse.julialang.org/u/clarakoehne)\
**Post date:** [November 7, 2022, 6:58am UTC](https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857/1 "2022-11-07T06:58:08Z")

</div>

Hi all! I am trying to compile my julia project using `PackageCompiler` v. 2.1.0. My julia version is 1.8.2, `Plots` is v. 1.35.8, `PyCall` 1.94.1 and, `PyPlot` 2.11.0. Compilation works, at least it doesn’t error in the middle. But when I start my compiled program, I get the following warning:

```julia
Warning: Error requiring `PyPlot` from `Plots`
│ exception =
│ LoadError: ArgumentError: ref of NULL PyObject
│ Stacktrace:
│ [1] _getproperty(o::PyCall.PyObject, s::String)
│ @ PyCall ~/.julia/packages/PyCall/ygXW2/src/PyCall.jl:299
│ [2] __getproperty
│ @ ~/.julia/packages/PyCall/ygXW2/src/PyCall.jl:312 [inlined]
│ [3] getproperty(o::PyCall.PyObject, s::String)
│ @ PyCall ~/.julia/packages/PyCall/ygXW2/src/PyCall.jl:317
│ [4] top-level scope
│ @ ~/.julia/packages/Plots/qgrW8/src/backends/pyplot.jl:25
│ [5] include(mod::Module, _path::RelocatableFolders.Path)
│ @ Base ./Base.jl:419
│ [6] include(x::RelocatableFolders.Path)
│ @ Plots ~/.julia/packages/Plots/qgrW8/src/Plots.jl:1
│ [7] top-level scope
│ @ ~/.julia/packages/Plots/qgrW8/src/init.jl:96
│ [8] eval
│ @ ./boot.jl:368 [inlined]
│ [9] eval
│ @ ~/.julia/packages/Plots/qgrW8/src/Plots.jl:1 [inlined]
│ [10] (::Plots.var"#378#423")()
│ @ Plots ~/.julia/packages/Requires/Z8rfN/src/require.jl:101
│ [11] macro expansion
│ @ ./timing.jl:382 [inlined]
│ [12] err(f::Any, listener::Module, modname::String, file::String, line::Any)
│ @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:47
│ [13] (::Plots.var"#377#422")()
│ @ Plots ~/.julia/packages/Requires/Z8rfN/src/require.jl:100
│ [14] withpath(f::Any, path::String)
│ @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:37
│ [15] (::Plots.var"#376#421")()
│ @ Plots ~/.julia/packages/Requires/Z8rfN/src/require.jl:99
│ [16] listenpkg(f::Any, pkg::Base.PkgId)
│ @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:20
│ [17] macro expansion
│ @ ~/.julia/packages/Requires/Z8rfN/src/require.jl:98 [inlined]
│ [18] __init__ ()
│ @ Plots ~/.julia/packages/Plots/qgrW8/src/init.jl:95
│ in expression starting at /home/clara/.julia/packages/Plots/qgrW8/src/backends/pyplot.jl:25
└ @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:51

```

It is still possible to call the help menu of my program though. But does anyone know how to avoid the warning shown above? Thanks a lot!

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 7, 2022, 7:56am UTC](https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857/2 "2022-11-07T07:56:42Z")

</div>

It looks like there might br a pointer that is trying to be serialized and deserialized, but it ends up being null since you cannot really save pointers.

The situation also appears complicated by the use of Requires.jl. Since you are compiling anyways there is no need for Requires.jl. Just include Plots.jl directly.

---

<div class="post-metadata">

**Author:** ![clarakoehne](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@clarakoehne](https://discourse.julialang.org/u/clarakoehne)\
**Post date:** [November 7, 2022, 7:59am UTC](https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857/3 "2022-11-07T07:59:48Z")

</div>

Okay… Thanks! I’m not really including `Requires` though, it comes in the `Plots` dependencies. But maybe then I just have to live with the warning…

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 8, 2022, 12:54pm UTC](https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857/4 "2022-11-08T12:54:10Z")

</div>

@stevengj , any thoughts about what might be happening here?

A test might be to use PyPlot.jl directky rather than through Plots.jl.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 8, 2022, 3:20pm UTC](https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857/5 "2022-11-08T15:20:04Z")

</div>

> [@clarakoehne](#):
>
> `LoadError: ArgumentError: ref of NULL PyObject`

This probably means that PyPlot had an error loading matplotlib, maybe because it’s missing from your Python install.

You may get a more detailed error message if you do `using PyPlot` directly.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 8, 2022, 6:26pm UTC](https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857/6 "2022-11-08T18:26:34Z")

</div>

Would any of the Python environment be captured during compilation?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 8, 2022, 6:42pm UTC](https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857/7 "2022-11-08T18:42:35Z")

</div>

The location of `libpython` and the Python path are set when you build PyCall. If you change these, you should re-run

```julia
pkg> build PyCall

```

at the package prompt.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 8, 2022, 6:47pm UTC](https://discourse.julialang.org/t/warning-error-requiring-pyplot-from-plots-in-compiled-julia-program/89857/8 "2022-11-08T18:47:41Z")

</div>

This is via the depsutils.jl file, right?

> <https://github.com/JuliaPy/PyCall.jl/blob/9f22684ab26231b1fba66d998e1fc25887f67ed5/src/PyCall.jl#L37>

I’m just thinking if PyCall.jl still knows where to look if it is compiled into the system image.

The other thing to mention here is that the system image itself is not meant to be fully portable at the moment. You may not be able to compile the system image on one computer and use it on another computer.

Let us know if any of this helps @clarakoehne .
