Unable to Plot in REPL

When I try to plot something in the Julia REPL, I am getting the following error messages.

julia> ENV[“GRDIR”] = “”
“”

julia> using Pkg

julia> Pkg.build(“GR”)

Building GR → “~/.julia/packages/GR/crXzk/deps/build.log”

julia> using Plots

julia> gr()
Plots.GRBackend()

julia> plot(rand(20))
/home/hunter/.julia/packages/GR/crXzk/src/…/deps/gr/bin/gksqt: error while loading shared libraries: libQtGui.so.4: 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

I have already tried the solution in

1 Like

Can you tell which version of Julia are you using? Try version() in the REPL and share it to us. On the other hand it just works for me for a fresh install. I just needed to install Plots.jl, Pkg.add("Plots"), and nothing else. Note that Plots.jl will install GR as the default backend

1 Like

Thanks for the reply! It looks like I accidentally submitted the post before finishing. I am using Julia 1.0.0, and I have installed it on openSUSE Tumbleweed. I have previously had this problem on Julia 0.6.4, too. I tried to follow the instructions in this post, but it did not work.

For openSUSE, you have to install the requirements as described in the installation instructions (Julia Package GR — GR Framework 0.66.0 documentation):

zypper install libXt6 libXrender1 libXext6 Mesa-libGL1 libQt5Widgets5

Thanks @jheinen, but unfortunately that did not solve the problem. I am still getting:

GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine FILLAREA

whenever I try to use GR as the plotting backend. Is there something else that could be causing an error?

Are there any system error message when gksqt is started, especially from the loader (ld) - missing libraries etc,?

The following was the output that I got:

hunter @ linux-ga1c ~/.julia/packages/GR/crXzk/deps/gr/bin
└─ $ :arrow_forward: ./gksqt
./gksqt: error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory

hunter @ linux-ga1c ~/.julia/packages/GR/crXzk/deps/gr/bin
└─ $ :arrow_forward: ld gksqt
ld: error in gksqt(.eh_frame); no .eh_frame_hdr table will be created.

When libQtGui.so.4 is not available, it’s most likely GR is not properly built. I ran into that recently. Check the log file “~/.julia/packages/GR/crXzk/deps/build.log” and see if it got to 100%.

Otherwise, rm GR (and you might have to remove the GR folder under .julia, I guess), and then add GR again.

It looks like the build got to 100%, but I went ahead and removed GR and added it again. I am still getting the same errors.

The generic Linux build (which is used on openSuSE) is built against Qt4. Could you pls try to install libQt4Widgets4? I don’t have an up-to-date openSuSE system - may be the name (libQt4Widgets4) is different.

1 Like

Sorry, I was misreading your error message. You definitely need Qt4 on your system.

Installing the package libqt4 fixed the problem. Thanks for all your help!

1 Like

I’ve got exactly the same error message in Gentoo Julia REPL while trying to plot(rand(100)) except for that instead of the following string:

I have yMV3y. However, I think that it is set randomly. The installed version of Julia is 1.3.0. The ~/.julia/packages/GR/yMV3y/deps/build.log file says that GR has been dowloaded pre-compiled though I have used pkg> build GR.
$ eix libqt command finds only dev-libs/libqtxdg package. Any ideas how to let the plot(rand(100)) command work in my Julia REPL on Gentoo? P.S. I am also going to ask this question on gentoo-user mailing list and point them here.

I have the same problem . How can I install package libqt4 ???