# Unable to plot from the REPL with PyPlot

**URL:** https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112
**Category:** Visualization
**Created:** [April 8, 2017, 12:06am UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112 "2017-04-08T00:06:51Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![adriano.vilela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adriano.vilela/32/7596_2.png) [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)
#### Post date: [April 8, 2017, 12:06am UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/1 "2017-04-08T00:06:51Z")

</div>

I recently decided to try Julia 0.6. I installed a Generic Linux binary (nightly build) on my machine. For plotting, I installed PyPlot, using my system’s installation of matplotlib (i.e., not Conda). Plotting works fine in IJulia, but I’m not able to plot from the REPL. Issuing a plot() command doesn’t create a window; it just prints a message like below in the REPL:

PyPlot.Figure(PyObject \<matplotlib.figure.Figure object at 0x7fa8653aa210\>)

I tried a ion() command before plotting, and also a show() command after plotting, but neither helped. I suspect this can have something to do with Matplotlib 2.0 (I use Debian testing and matplotlib was recently upgraded from version 1.5 to 2.0). Does anybody have any pointers as to how I should go about debugging this?

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [April 8, 2017, 12:33am UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/2 "2017-04-08T00:33:40Z")

</div>

Did you try using the version via Conda?

---

<div class="post-metadata">

### Author: ![TsurHerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsurherman/32/1234_2.png) [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)
#### Post date: [April 8, 2017, 9:23am UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/3 "2017-04-08T09:23:06Z")

</div>

I had this issue and it went away either by re-installing anaconda distro (so maybe try just reinstalling matplotlib?)

Or by reinstalling PyCall and PyPlot

So probably this is not very helpful as it does not point to the root .

Maybe even just a restart would do it , cause it seems to me that the problem is that it gets plotted but nowhere where it is visible … maybe in another process?

---

<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: [April 8, 2017, 2:51pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/4 "2017-04-08T14:51:31Z")

</div>

What is `PyPlot.backend`?

---

<div class="post-metadata">

### Author: ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)
#### Post date: [April 8, 2017, 4:08pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/5 "2017-04-08T16:08:13Z")

</div>

I found I need to invoke `pygui(true)` to get a plot window from the REPL, with latest tagged PyPlot and a recent build of Julia v0.6.beta. (Also using Matplotlib 2.0 and the Qt5 backend, as installed by Conda.jl, on Linux.)

Further, if one uses PyPlot as a backend for Plots.jl in the above environment, this seems to work:

```julia
using Plots
import PyPlot: pygui
PyPlot.pygui(true)
# now ready to call Plots methods

```

otherwise Plots thinks PyPlot is not properly installed.

---

<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: [April 8, 2017, 4:23pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/6 "2017-04-08T16:23:43Z")

</div>

> [@Ralph\_Smith](#):
>
> I found I need to invoke pygui(true) to get a plot window from the REPL, with latest tagged PyPlot and a recent build of Julia v0.6.beta.

I can’t reproduce; it works fine for me without `pygui`. Do you have something in your `.juliarc` that would affect it?

---

<div class="post-metadata">

### Author: ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)
#### Post date: [April 8, 2017, 4:29pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/7 "2017-04-08T16:29:21Z")

</div>

I don’t have a `.juliarc` or anything I can find in the environment or dot-files that should affect PyPlot/matplotlib. I’ll try stepping through the ` __init__ ` calls to see if I can find the problem.

After some investigation… for me (i.e. using Conda.jl) it seems to be a case of  
[https://github.com/JuliaPy/PyPlot.jl/issues/281](https://github.com/JuliaPy/PyPlot.jl/issues/281)  
which is fixed in PyPlot master. In short, under Julia v0.6 version 2.3.1 of PyPlot acts as if the REPL is a graphical display and switches Matplotlib’s own backend to “Agg”.

I still need the above hack for Plots (with PyPlot master), but I’m waiting for Plots to be happier with v0.6 before investigating.

---

<div class="post-metadata">

### Author: ![adriano.vilela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adriano.vilela/32/7596_2.png) [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)
#### Post date: [April 8, 2017, 5:30pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/8 "2017-04-08T17:30:43Z")

</div>

@dpsanders Yes, I did try with Conda but that didn’t help.

@stevengj PyPlot.backend is “qt5agg”. However, I tried different backends with the sequence below (as explained in the PyPlot documentation), but that didn’t help either:

```julia
using PyCall
pygui(gui)
using PyPlot

```

The values I tried for `gui` were (:tk, :gtk3, :gtk, :qt5, :qt4, :qt, :wx). None of them worked (some of them actually threw an error as I don’t have the required libraries for all of them installed on my system).

Doing `pygui(true)` before plotting as suggested by Ralph\_Smith does solve the problem, but only when using Conda. If I uninstall PyPlot and PyCall and reinstall them using my system’s Python and matplotlib installations, Julia simply quits with the following error message when I try to plot something:

```julia
: CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

```

In summary, if I use Conda, I have to use `pygui(true)` in order to be able to plot. If I use my system’s Python and matplotlib, I can’t plot because of the error above.

---

<div class="post-metadata">

### Author: ![adriano.vilela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adriano.vilela/32/7596_2.png) [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)
#### Post date: [April 9, 2017, 2:10am UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/9 "2017-04-09T02:10:10Z")

</div>

After some more investigation, I found out that I didn’t have the tk backend installed on my system. I installed it and now I can open a plot window after I issue the following commands:

```julia
using PyCall
pygui(:tk)
using PyPlot
pygui(true)

```

However, if I try any other backends, Julia quits with the error message below when I try to plot something:

```julia
: CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

```

I switched to PyPlot master and things changed. Before switching to master, issuing a `figure()` command in the terminal didn’t open a window plot; it just printed a message like below in the terminal:

PyPlot.Figure(PyObject )

Only after doing `pygui(true)` and then trying to plot again I would get the LLVM error above. After switching to PyPlot master, any attempt to create a window plot (e.g., `figure()`) results in the LLVM error; now I don’t need to do `pygui(true)` in order to cause that. However, using the tk backend still works.

---

<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: [April 9, 2017, 10:54am UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/10 "2017-04-09T10:54:33Z")

</div>

> [@adriano.vilela](#):
>
> CommandLine Error: Option ‘help-list’ registered more than once

Apparently that is a problem due to conflicting versions of LLVM. Julia is linked against the LLVM shared library, but one of the Matplotlib backends is linking a different version: [Add a build option to rename all LLVM symbols · Issue #12644 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/12644)

---

<div class="post-metadata">

### Author: ![adriano.vilela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adriano.vilela/32/7596_2.png) [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)
#### Post date: [April 9, 2017, 5:45pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/11 "2017-04-09T17:45:09Z")

</div>

@stevengj Thanks. There are two weird things about this though. First, the version of my system’s LLVM is 3.9.1, exactly the same reported by Julia 0.6. Second, if I try to uninstall my system’s LLVM package (using Debian apt-get tools), no matplotlib related package (not even any of its backend packages) gets uninstalled, which, as far as I understand, means that no matplotlib or matplotlib backend package depends on LLVM.

I noticed there’s a more up-to-date version of libllvm in Debian’s experimental repository which fixes a couple of bugs. I installed it but the problem persists.

I then decided to compile Julia from source against my system’s LLVM installation. That solves the problem. However, I still have to do `pygui(true)` before I’m able to get a window plot.

---

<div class="post-metadata">

### Author: ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)
#### Post date: [April 9, 2017, 6:15pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/12 "2017-04-09T18:15:07Z")

</div>

Are you on PyPlot master? That should obviate the need for `pygui(true)` (see edited post upthread).

LLVM is linked by some low level Debian packages such as OpenGL-related libraries, which may be called by the matplotlib backends as needed (i.e. without explicit APT dependencies). Others have reported LLVM consistency problems in the context of OpenGL/CL Julia packages.

---

<div class="post-metadata">

### Author: ![adriano.vilela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adriano.vilela/32/7596_2.png) [@adriano.vilela](https://discourse.julialang.org/u/adriano.vilela)
#### Post date: [April 9, 2017, 6:35pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/13 "2017-04-09T18:35:59Z")

</div>

You’re right. Switching to PyPlot master does obviate the need for `pygui(true)`. Thanks.

In summary, PyPlot master with the tk backend allows me to have a plotting system working again without having to rely on Conda (this saves me 1.3 GB of files pulled in by the Conda installation; I already have all the necessary libraries installed on my system for Python development).

Regarding the LLVM issue, is this something I should report to the Debian bug tracking system or is it just a matter of waiting for issue #12644 to be fixed?

---

<div class="post-metadata">

### Author: ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)
#### Post date: [April 9, 2017, 7:13pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/14 "2017-04-09T19:13:52Z")

</div>

I don’t think its a bug in Debian - the dependency seems indirect and probably depends on one’s hardware/drivers. Let’s hope #12644 is addressed before too many more of us stumble into it.

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)
#### Post date: [July 11, 2017, 7:49pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/15 "2017-07-11T19:49:44Z")

</div>

In the short term, on Linux it may be helpful to try `dlopen` with `Libdl.RTLD_DEEPBIND` as an argument. Make sure this is done for the first `dlopen` of a given shared object, because subsequent calls will return the existing handle without re-evaluating any load options.

---

<div class="post-metadata">

### Author: ![shyampatadia22](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shyampatadia22/32/34803_2.png) [@shyampatadia22](https://discourse.julialang.org/u/shyampatadia22)
#### Post date: [June 30, 2022, 4:06pm UTC](https://discourse.julialang.org/t/unable-to-plot-from-the-repl-with-pyplot/3112/16 "2022-06-30T16:06:57Z")

</div>

It worked for me as well than you very much!!
