GR doesn't work in Julia

I need some help. I am using gr backend but it doesn’t work with the error

using Plots
x = 1:10; y = rand(10); # These are the plotting data

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

gr()
plot(x, y, title = "Two Lines", label = ["Line 1" "Line 2"], lw = 3)

ERROR: could not load library “libGR.so”
dlopen(libGR.so.dylib, 0x0001): tried: ‘/Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libGR.so.dylib’ (no such file), ‘/Applications/Julia-1.8.app/Contents/Resources/julia/bin/…/lib/libGR.so.dylib’ (no such file), ‘libGR.so.dylib’ (no such file), ‘/usr/local/lib/libGR.so.dylib’ (no such file), ‘/usr/lib/libGR.so.dylib’ (no such file), ‘/Users/kaihara/Desktop/Programming/libGR.so.dylib’ (no such file), ‘/usr/local/lib/libGR.so.dylib’ (no such file), ‘/usr/lib/libGR.so.dylib’ (no such file)

Why did you set GRDIR? Did the defaults not work?

It should work with just a using Plots. No need to explicitly install or build GR.

1 Like

Thank you for your reply.

I have the same error when

using Plots
x = 1:10; y = rand(10); # These are the plotting data
plot(x, y)

please uninstall GR and re-build Plots.jl by itself

I executed

Pkg.rm("GR")
Pkg.rm("Plots")
Pkg.add("Plots")

But I got the same error.

Pkg.add("Plots")
Pkg.add("GR")
Pkg.build("GR")
<restart Julia>

I restarted Julia but I have gotten the same error

We’ve had issues for the GR@0.68GR@0.69 transition.

What are your Plots and GR versions ?

See also VS Code 1.7.1.2 and Plots.jl not working (even though on windows, similar).

I am using GR@0.68. Plots@1.34.4

Then this should work:

(@v1.8) pkg> build GR
julia> using Plots
julia> x = 1:10; y = rand(10);
julia> plot(x, y, title = "Two Lines", label = ["Line 1" "Line 2"], lw = 3)

If not, search for libGR in ~/.julia/artifacts, delete the corresponding ~/.julia/artifacts/<sha1>, then run

(@v1.8) pkg> instantiate
  Downloaded artifact: GR

it should download the GR artifact again, you can then retry.

Did you download the official binaries at Download Julia to setup julia ?

1 Like

It worked!! Thank you for your help.