Simple plotting, I am getting *could not load library "libGR.so"*

Hello Julia experts,
Please help me get a plot.
I am almost done with my first assignment using Julia and got to a stage where I need at least a plot.
My code for the plotting is:
x = Rating_count.Ratings; y = Rating_count.count;
plot(x, y, title = “The great title.”,
label = [“Number of something”], lw =3)
xlabel!(“Ratings”)
ylabel!(“Count of something”)

and I get:

1 Like

Hi @mausam614,

to use the GR backend you also need the GR package.
Did you added it?:

Pkg.add("GR")

Not earlier but I used it now,

Pkg.add(“GR”)
Pkg.add(“Plots”)
Pkg.add(“StatsPlots”)
using StatsPlots
using GR
using Plots

I am getting the same message.

Appreciate your help.

To properly install GR, have a look here:

Note also that to get a plot through StatsPlots all you need is using StatsPlots, so, you install the packages:

Pkg.add(“GR”)
Pkg.add(“Plots”)
Pkg.add(“StatsPlots”)

Then:
using StatsPlots

1 Like

The GR run-time is probably missing:

ENV["GRDIR"]=""
] build GR
2 Likes

Thank you so much.

Solved, thanks a lot.

This is weird. I’ve been using 1.7.3 since it arrived. I use plotting every day on around 100 Pluto notebooks. I haven’t changed configurations. I last used Pluto and plotting 2 days ago, but this morning I sat down to do some work and got this on the first Pluto notebook I opened:

Failed to show value:
could not load library “libGR.so”
dlopen(libGR.so.dylib, 0x0001): tried: ‘/Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libGR.so.dylib’ (no such file), …

Following the advice in this thread I’ve tried:

  1. ENV[“GRDIR”] = “”
    Pkg.build(“GR”)

This didn’t help.

  1. restart Julia, then ] update

Still same problem.

Here is the output from:

julia> using GR

julia> readdir(joinpath(ENV[“GRDIR”], “lib”))
23-element Vector{String}:
“aggplugin.so”
“cairoplugin.so”
“glplugin.so”
“gr.js”
“gsplugin.so”
“gtkplugin.so”
“libGKS.dylib”
“libGR.dylib”
“libGR3.dylib”
“libGRM.dylib”
“libqt5gr.dylib”
“libqt6gr.dylib”
“pgfplugin.so”
“qt5plugin.so”
“qt6plugin.so”
“qtplugin.so”
“quartzplugin.so”
“svgplugin.so”
“videoplugin.so”
“wmfplugin.so”
“wxplugin.so”
“x11plugin.so”
“zmqplugin.so”

So, it appears that I’ve got libGR.dylib, but the message says it’s missing libGR.so.dylib.

I’ve got no idea what could have happened.

I solved this by cd into join path(ENV[“GRDIR”], “lib”) and copying libGR.dylib to libGR.so.dylib.

I can work again, but I still don’t have a clue why this happened.

That is weird. Why would there be a “.so.dylib”? Why are there .so and .dylib on the same system.

If it helps, I think I was hit in Win11 Julia 1.7.3 by a similar problem when trying to plot with gr() backend, getting: ERROR: could not load library "libGR.dll.

The problem was that the project environment had old versions of Plots.jl and GR.jl installed, and I couldn’t update them as compatibility with some other package was blocking it.

By forcing an update, we can see which package was blocking the update of Plots.jl:
] add Plots@1.31.2

I removed the problematic package and did update and rebuild in the package manager. Then I restarted and voilà, Plots.jl was back in business.