The following GKS error is thrown when plotting in vscode. When I try the same plot in Juno or Linux bash terminal no error is thrown. I understand the problem is not directly related to julia-vscode extension but is caused by some kind of Qt error. I am using GR as the backend of Plots and I have already installed additional dependencies of GR for Debian/Linux.
I am particularly surprised that this error is thrown when I try to plot in vscode only. No error is thrown in Linux bash terminal or Juno.
Any ideas on how to fix this?
julia> using Plots
julia> plot()
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.
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
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 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 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
$ sudo apt install libx11-xcb1
Reading package lists... Done
Building dependency tree
Reading state information... Done
libx11-xcb1 is already the newest version (2:1.6.4-3ubuntu0.2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Here are the locations of libx11-xcb1 in the system
Yes. A svg plot is created in VSCode. I can also switch to png. But the plots are not the same as those when I plot them in bash terminal. Specifically, the grids and backgrounds are different.
Here is the case when I plot in VSCode.
julia> using GR
julia> inline("svg")
"svg"
julia> plot(rand(10))
julia> inline("png")
"png"
julia> plot(rand(10))
Right now I’m a little at a loss. I would have to try to reproduce it somewhere, but I don’t have a comparable system at the moment. This is about Debian with a current VSCode? Exact version information would be helpful - with that I would try to recreate it on Monday.
Setting ENV["GKSwstype"] = "100" (in startup.jl to avoid setting all the time Julia is launched) solved the problem. Now nothing wrong with using GR as a backed of Plots in VSCode.
If you mean I should copy and paste this code ENV[“GKSwstype”] = “100” on Julia and press Enter. I did but still there is no plot.
I am a newbie in Julia and I am not familiar with Julia. I only use Matlab and a little Python
I don’t know why the shape of Julia is not complete and doesn’t have any color. maybe it has something to do with this problem???
I installed the same atoms and Julia on my friend’s loptop which has windows 7 . it works and I did my project but I want it on my loptop.
You can copy and paste ENV[“GKSwstype”] = “100” in the repl. However, once the repl is relaunched, you must repeat this again. To avoid setting this all the time the repl is launched, you can write this setting in your .startup.jl file.
This file should be located somewhere like C:\Users\USERNAME\.julia\config\startup.jl. So, you need to open and add the line ENV[“GKSwstype”] = “100” in the startup.jl file. If the file is not present, you should create it on your own.
To check if the file exits in your system, you can follow these steps.
using Pkg
depotpath = first(Pkg.depots()) # The output should something like `C:\Users\USERNAME\.julia`
configdir = joinpath(depotpath, "config")
isdir(configdir) || mkdir(config) # Check if config directory exists, if not construct it.
configfile = joinpath(configdir, "startup.jl")
isfile(configfile) || touch(configfile) # Check if startup.jl exits, if not construct it
To open startup.jl file in a text editor like atom and edit it manually, you can specify the editor
ENV["EDITOR"] = "atom" # Choose whichever editor your prefer. Here I choose atom from your screenshot
edit(configfile)
At this point, the file should be opened in the atom editor and you can edit it. Just add the line ENV[“GKSwstype”] = “100” in the file, save and close. Now you are all done. To check, close and relaunch the repl, and type
We have decided to join forces with the Julia extension for VSCode. As such, this Atom-based plugin is effectively in “maintenance-only mode” and we expect to only work on bug fixes in the future.
Thanks for the detaiIed explanation. I did step by step as you mentioned but when I saved the ENV[“GKSwstype”] = “100” in startup.jl
the EPRL doesn’t work.
when I delete that code (ENV[“GKSwstype”] = “100”) from startup.jl and save it .
The EPRL works.
I don’t know why the plotly work but plot doesn’t work. I think it is better to use another IDE instead of Atoms
There is no reason to change GKS_WSTYPE in Atom. GR (or Plots) will recognize that Atom is running and produce plots in the Plots pane. The only thing you might have to change is the color theme (usecolorscheme(2) for dark mode):