# Unable to display plot using the REPL. GKS errors

**URL:** <https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826>\
**Category:** New to Julia\
**Created:** [August 2, 2018, 3:18pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826 "2018-08-02T15:18:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![DomCaron](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@DomCaron](https://discourse.julialang.org/u/DomCaron)\
**Post date:** [August 2, 2018, 3:18pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/1 "2018-08-02T15:18:22Z")

</div>

I recently changed my OS to Ubuntu on my laptop and reinstalled Julia. When trying to plot something, I have the following messages:

```julia
julia> using Plots

julia> plot(randn(20))
/home/dcaron/.julia/v0.6/GR/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
Did you start 'gksqt'?

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine FILLAREA
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine FILLAREA
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE

```

On Atom, i am able to display plots, so i am guessing it is a problem related with the package GR.

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [August 2, 2018, 3:30pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/2 "2018-08-02T15:30:38Z")

</div>

It seems that the `Qt5` run-time is missing on your laptop.

```bash
sudo apt-get install qt5-default

```

should fix the problem.

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [August 2, 2018, 3:32pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/3 "2018-08-02T15:32:17Z")

</div>

If this doesn’t help, ensure that the GR run-time is up-to-date:

```julia
ENV["GRDIR"] = ""
Pkg.build("GR")

```

---

<div class="post-metadata">

**Author:** ![DomCaron](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@DomCaron](https://discourse.julialang.org/u/DomCaron)\
**Post date:** [August 2, 2018, 6:20pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/4 "2018-08-02T18:20:33Z")

</div>

It worked, thanks a lot!

---

<div class="post-metadata">

**Author:** ![spk57](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/spk57/32/4781_2.png) [@spk57](https://discourse.julialang.org/u/spk57)\
**Post date:** [January 11, 2019, 12:50pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/5 "2019-01-11T12:50:06Z")

</div>

Thanks for posting. I had same error with new Ubuntu 18.04.1 LTS distro / Julia 1.0.3. installing qt5-default resolved issue.

---

<div class="post-metadata">

**Author:** ![Freed-Wu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freed-wu/32/204089_2.png) [@Freed-Wu](https://discourse.julialang.org/u/Freed-Wu)\
**Post date:** [April 26, 2020, 7:33am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/6 "2020-04-26T07:33:58Z")

</div>

I met this error. but i use gentoo not debian so i cannot run `apt install`. how can i do to solve this problem?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 26, 2020, 7:44am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/7 "2020-04-26T07:44:02Z")

</div>

Use whatever mechanism Gentoo prefers for installing software (I think it is called `emerge`, but I never used Gentoo much).

---

<div class="post-metadata">

**Author:** ![Freed-Wu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freed-wu/32/204089_2.png) [@Freed-Wu](https://discourse.julialang.org/u/Freed-Wu)\
**Post date:** [April 26, 2020, 10:08am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/8 "2020-04-26T10:08:11Z")

</div>

```julia
error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory

```

i have installed `qtgui-5.13.2` in my gentoo. but it still display this error… i wanna try to whether updating qtgui can solve this error…

---

<div class="post-metadata">

**Author:** ![Freed-Wu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freed-wu/32/204089_2.png) [@Freed-Wu](https://discourse.julialang.org/u/Freed-Wu)\
**Post date:** [April 26, 2020, 3:43pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/9 "2020-04-26T15:43:47Z")

</div>

i have update qtgui to 5.14.1-r4. it still return this error. ☹

---

<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 26, 2020, 4:05pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/10 "2020-04-26T16:05:39Z")

</div>

The GR backend is trying to fall back to Qt4, but you have installed Qt5. Did you do the above-mentioned rebuild of GR.jl _after_ the latest install of Qt5?

---

<div class="post-metadata">

**Author:** ![Freed-Wu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freed-wu/32/204089_2.png) [@Freed-Wu](https://discourse.julialang.org/u/Freed-Wu)\
**Post date:** [April 27, 2020, 5:24am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/11 "2020-04-27T05:24:03Z")

</div>

```julia
] build GR

```

i have builded GR. is it wrong? what should i do?

---

<div class="post-metadata">

**Author:** ![Freed-Wu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freed-wu/32/204089_2.png) [@Freed-Wu](https://discourse.julialang.org/u/Freed-Wu)\
**Post date:** [April 27, 2020, 5:32am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/12 "2020-04-27T05:32:30Z")

</div>

let me try to make sciapp/gr…

---

<div class="post-metadata">

**Author:** ![Freed-Wu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freed-wu/32/204089_2.png) [@Freed-Wu](https://discourse.julialang.org/u/Freed-Wu)\
**Post date:** [April 27, 2020, 5:48am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/13 "2020-04-27T05:48:43Z")

</div>

although it has an error `qt.qpa.xcb: QXcbConnection: XCB error: 146 (Unknown), sequence: 201, resource id: 0, major code: 139 (Unknown), minor code: 20` , but the figure appears successful! thanks!

---

<div class="post-metadata">

**Author:** ![Samuel\_Ainsworth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuel_ainsworth/32/15644_2.png) [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Post date:** [July 23, 2020, 12:00am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/14 "2020-07-23T00:00:02Z")

</div>

Is there any workaround for those of us who need to work on machines that we don’t have sudo access to?

Also why does GR require Qt5? I’m running completely headless…

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [July 23, 2020, 1:29am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/15 "2020-07-23T01:29:09Z")

</div>

On headless systems, pls set the environment `GKS_WSTYPE` to `nul` or `100`.

---

<div class="post-metadata">

**Author:** ![Samuel\_Ainsworth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuel_ainsworth/32/15644_2.png) [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Post date:** [July 23, 2020, 1:43am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/16 "2020-07-23T01:43:01Z")

</div>

I tried both of these settings but they give me an error:

```julia
ERROR: LoadError: SystemError: opening file "/tmp/jl_CdHheQ.png": No such file or directory
Stacktrace:
 [1] systemerror(::String, ::Int32; extrainfo::Nothing) at ./error.jl:168
 [2] #systemerror#50 at ./error.jl:167 [inlined]
 [3] systemerror at ./error.jl:167 [inlined]
 [4] open(::String; read::Nothing, write::Nothing, create::Nothing, truncate::Nothing, append::Nothing) at ./iostream.jl:254
 [5] open at ./iostream.jl:246 [inlined]
 [6] open(::Base.var"#279#280"{String}, ::String; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at ./io.jl:296
 [7] open at ./io.jl:296 [inlined]
 [8] read at ./io.jl:381 [inlined]
 [9] _show(::IOStream, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.GRBackend}) at /home/skainswo/.julia/packages/Plots/VA7Vx/src/backends/gr.jl:1970
 [10] show at /home/skainswo/.julia/packages/Plots/VA7Vx/src/output.jl:215 [inlined]
 [11] png(::Plots.Plot{Plots.GRBackend}, ::String) at /home/skainswo/.julia/packages/Plots/VA7Vx/src/output.jl:7
 [12] frame(::Plots.Animation, ::Plots.Plot{Plots.GRBackend}) at /home/skainswo/.julia/packages/Plots/VA7Vx/src/animation.jl:20
 [13] frame(::Plots.Animation) at /home/skainswo/.julia/packages/Plots/VA7Vx/src/animation.jl:18
 [14] top-level scope at /home/skainswo/dev/research/julia/odecontrol/diffdrive/train.jl:89
 [15] include(::Module, ::String) at ./Base.jl:377
 [16] exec_options(::Base.JLOptions) at ./client.jl:288
 [17] _start() at ./client.jl:484
in expression starting at /home/skainswo/dev/research/julia/odecontrol/diffdrive/train.jl:48

```

Also, is there documentation for this somewhere?

EDIT: Tried a value of 140 as suggested in [https://github.com/JuliaPlots/Plots.jl/issues/1612](https://github.com/JuliaPlots/Plots.jl/issues/1612) and that worked 🤷‍♂️ Magic numbers galore!

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [July 23, 2020, 5:49am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/17 "2020-07-23T05:49:07Z")

</div>

Sorry - my fault. I didn’t realize that you are using `Plots`. That’s an example for headless systems:

```julia
ENV["GKSwstype"] = "nul"
using Plots
plot(rand(10))
savefig("foo.png")

```

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [July 23, 2020, 7:16pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/18 "2020-07-23T19:16:30Z")

</div>

I am also getting these errors:

```julia
julia> plot(rand(10))
/home/affans/.julia/packages/GR/Atztx/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

```

Setting `ENV["GKSwstype"] = "nul"` or `ENV["GKSwstype"] = "140"` works but `plot(rand(10))` dosn’t really do anything (I am using an X-server to pop up the image from my server to local). So anyway I can get this to work on a server (without sudo access, so can’t install Qt5Widgets.so.5) and with x-forwarding?

---

<div class="post-metadata">

**Author:** ![Samuel\_Ainsworth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuel_ainsworth/32/15644_2.png) [@Samuel\_Ainsworth](https://discourse.julialang.org/u/Samuel_Ainsworth)\
**Post date:** [July 25, 2020, 3:04am UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/19 "2020-07-25T03:04:33Z")

</div>

> ENV[“GKSwstype”] = “nul”

This did the trick for me! Thanks!

---

<div class="post-metadata">

**Author:** ![txrvl](https://avatars.discourse-cdn.com/v4/letter/t/258eb7/32.png) [@txrvl](https://discourse.julialang.org/u/txrvl)\
**Post date:** [October 22, 2020, 5:19pm UTC](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/20 "2020-10-22T17:19:58Z")

</div>

For gentoo users 🙂  
euse -p sci-visualization/gr -E cairo  
emerge --ask --verbose sci-visualization/gr  
source /etc/profile

[Next page](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826.md?page=2)
