jheinen / GR.jl

Plotting for Julia based on GR, a framework for visualisation applications
Other
356 stars 76 forks source link

Could not load library "LibGR.so" on Julia v. 0.6.2, MacOS #107

Closed hypponen closed 6 years ago

hypponen commented 6 years ago

Having an issue with GR on Julia with Plots. Can't produce any plots that use GR, due to libGR.so missing. Here's an example:

julia> using Plots, DataFrames

julia> gr()

Plots.GRBackend()

julia> df = DataFrame(a = 1:10, b = 10*rand(10))
10×2 DataFrames.DataFrame
│ Row │ a  │ b        │
├─────┼────┼──────────┤
│ 1   │ 1  │ 5.73511  │
│ 2   │ 2  │ 9.30426  │
│ 3   │ 3  │ 1.99164  │
│ 4   │ 4  │ 0.15382  │
│ 5   │ 5  │ 0.650482 │
│ 6   │ 6  │ 3.12538  │
│ 7   │ 7  │ 3.15308  │
│ 8   │ 8  │ 1.79081  │
│ 9   │ 9  │ 2.85802  │
│ 10  │ 10 │ 0.408812 │

julia> Plots.scatter(df[:a], df[:b])
ERROR: error compiling _do_plot_show: error compiling _display: could not load library "libGR.so"
dlopen(libGR.so.dylib, 1): image not found
Stacktrace:
 [1] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Array{Int64,1},Array{Float64,1}}) at /Users/jaakko/.julia/v0.6/Plots/src/plot.jl:246
 [2] #plot#202(::Array{Any,1}, ::Function, ::Array{Int64,1}, ::Vararg{Any,N} where N) at /Users/jaakko/.julia/v0.6/Plots/src/plot.jl:58
 [3] (::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::Array{Int64,1}, ::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N) at ./<missing>:0
 [4] #scatter#662(::Array{Any,1}, ::Function, ::Array{Int64,1}, ::Vararg{Any,N} where N) at /Users/jaakko/.julia/v0.6/RecipesBase/src/RecipesBase.jl:381
 [5] scatter(::Array{Int64,1}, ::Vararg{Any,N} where N) at /Users/jaakko/.julia/v0.6/RecipesBase/src/RecipesBase.jl:381
jheinen commented 6 years ago

Please update and rebuild GR:

ENV["GRDIR"]=""
Pkg.update()
Pkg.build("GR")
hypponen commented 6 years ago

Thanks for the quick reply jheinen!

Unfortunately, the problem still persists. Any idea what else could I try to troubleshoot?

julia> ENV["GRDIR"]=""
""

julia> Pkg.update()
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or remove

julia> Pkg.build("GR")
INFO: Building GR

julia> using Plots, DataFrames

julia> gr()
Plots.GRBackend()

julia> df = DataFrame(a = 1:10, b = 10*rand(10))
10×2 DataFrames.DataFrame
│ Row │ a  │ b        │
├─────┼────┼──────────┤
│ 1   │ 1  │ 2.96857  │
│ 2   │ 2  │ 9.94598  │
│ 3   │ 3  │ 1.70888  │
│ 4   │ 4  │ 3.49718  │
│ 5   │ 5  │ 0.946341 │
│ 6   │ 6  │ 5.70872  │
│ 7   │ 7  │ 6.58371  │
│ 8   │ 8  │ 2.62883  │
│ 9   │ 9  │ 3.87819  │
│ 10  │ 10 │ 6.79393  │

julia> Plots.scatter(df[:a], df[:b])
ERROR: error compiling _do_plot_show: error compiling _display: could not load library "libGR.so"
dlopen(libGR.so.dylib, 1): image not found
Stacktrace:
 [1] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Array{Int64,1},Array{Float64,1}}) at /Users/jaakko/.julia/v0.6/Plots/src/plot.jl:246
 [2] #plot#202(::Array{Any,1}, ::Function, ::Array{Int64,1}, ::Vararg{Any,N} where N) at /Users/jaakko/.julia/v0.6/Plots/src/plot.jl:58
 [3] (::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::Array{Int64,1}, ::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N) at ./<missing>:0
 [4] #scatter#662(::Array{Any,1}, ::Function, ::Array{Int64,1}, ::Vararg{Any,N} where N) at /Users/jaakko/.julia/v0.6/RecipesBase/src/RecipesBase.jl:381
 [5] scatter(::Array{Int64,1}, ::Vararg{Any,N} where N) at /Users/jaakko/.julia/v0.6/RecipesBase/src/RecipesBase.jl:381

julia> 
floswald commented 6 years ago

same problem on ubuntu:

julia> p = Plots.scatter(df[:a], df[:b])
ERROR: error compiling _do_plot_show: error compiling _display: could not load library "libGR.so"
libXt.so.6: cannot open shared object file: No such file or directory
Stacktrace:
 [1] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Array{Int64,1},Array{Float64,1}}) at /var/lib/buildkite-agent/.julia/v0.6/Plots/src/plot.jl:246
 [2] #plot#208(::Array{Any,1}, ::Function, ::Array{Int64,1}, ::Vararg{Any,N} where N) at /var/lib/buildkite-agent/.julia/v0.6/Plots/src/plot.jl:58
 [3] (::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::Array{Int64,1}, ::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N) at ./<missing>:0
 [4] #scatter#676(::Array{Any,1}, ::Function, ::Array{Int64,1}, ::Vararg{Any,N} where N) at /var/lib/buildkite-agent/.julia/v0.6/RecipesBase/src/RecipesBase.jl:385
 [5] scatter(::Array{Int64,1}, ::Vararg{Any,N} where N) at /var/lib/buildkite-agent/.julia/v0.6/RecipesBase/src/RecipesBase.jl:385

julia> Pkg.status("GR")
 - GR                            0.31.0

julia> 
jheinen commented 6 years ago

For Ubuntu, you have to install some system packages, as mentioned on the home page:

apt install libxt6 libxrender1 libgl1-mesa-glx
floswald commented 6 years ago

yes! works.

I see that

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

but the savefig command works, which is fine for me since remote connection without screen.

jheinen commented 6 years ago

Can you open a simple Xlib client, e.g. xclock?

floswald commented 6 years ago

i installed it with sudo apt-get install x11-apps and see the below. note again that I don't want a display in this case and stuff is actually working. I just wonder how to tell GR that I'm headless.

buildkite-agent@build1:~/.julia/v0.6/Fertility$ xclock
Error: Can't open display: 

buildkite-agent@build1:~/.julia/v0.6/Fertility$ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia> using Plots

julia> plot(rand(10))
sh: 0: getcwd() failed: No such file or directory
QXcbConnection: Could not connect to display
Aborted
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

julia> 
jheinen commented 6 years ago

On a headless system, you will have to change the default workstation type to PDF, SVG or an image format before import GR, e.g.

jheinen commented 6 years ago

You can alsi use GKSwstype=100, to disable any "interactive" output (and limit graphics output to savefig())

ghaspias commented 6 years ago

The same is happening on Windows 10:

julia> using GR

julia> histogram(randn(10000)) ERROR: error compiling #histogram#33: error compiling plot_data: error compiling clearws: could not load library "libGR.dll" The operation completed successfully.

Stacktrace: [1] #histogram#13 at C:\Users\Miguel.julia\v0.6\GR\src\GR.jl:2963 [inlined] [2] histogram(::Array{Float64,1}) at C:\Users\Miguel.julia\v0.6\GR\src\GR.jl:2963

Removing, reinstalling, rebuilding doesn't fix it.

jheinen commented 6 years ago

Did you update and rebuild with GRDIR=""?

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

This should download the latest GR run-time.

erzauge commented 6 years ago

hi I have the same problem and tried to rebuild it

Pkg.update()
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or remove

julia> ENV["GRDIR"]=""
""

julia> Pkg.build("GR")
INFO: Building GR

julia> plot(x,y)
ERROR: error compiling #plot#27: error compiling plot_data: error compiling clearws: could not load library "libGR.so"
libGR.so: Kann die Shared-Object-Datei nicht öffnen: Datei oder Verzeichnis nicht gefunden
Stacktrace:
Stacktrace:
 [1] plot(::UnitRange{Int64}, ::Vararg{Union{AbstractArray{T,1} where T, AbstractArray{T,2} where T, AbstractString, Function},N} where N) at /users/student/wuma8935/.julia/v0.6/GR/src/jlgr.jl:1057
 [2] #plot#6(::Array{Any,1}, ::Function, ::UnitRange{Int64}, ::Vararg{Any,N} where N) at /users/student/wuma8935/.julia/v0.6/GR/src/GR.jl:2956
 [3] plot(::UnitRange{Int64}, ::Vararg{Any,N} where N) at /users/student/wuma8935/.julia/v0.6/GR/src/GR.jl:2956

and lookt if the required libaris are installed

$ ldconfig -p | grep libXt
    libXtst.so.6 (libc6,x86-64) => /lib64/libXtst.so.6
    libXtst.so (libc6,x86-64) => /lib64/libXtst.so
    libXt.so.6 (libc6,x86-64) => /lib64/libXt.so.6
    libXt.so (libc6,x86-64) => /lib64/libXt.so
$ ldconfig -p | grep libXrender
    libXrender.so.1 (libc6,x86-64) => /lib64/libXrender.so.1
    libXrender.so (libc6,x86-64) => /lib64/libXrender.so
$ ldconfig -p | grep libXext
    libXext.so.6 (libc6,x86-64) => /lib64/libXext.so.6
    libXext.so (libc6,x86-64) => /lib64/libXext.so
$ ldconfig -p | grep mesa-libGL
$ ldconfig -p | grep libGL
    libGLU.so.1 (libc6,x86-64) => /lib64/libGLU.so.1
    libGLU.so (libc6,x86-64) => /lib64/libGLU.so
    libGLEW.so.1.10 (libc6,x86-64) => /lib64/libGLEW.so.1.10
    libGLESv2.so.2 (libc6,x86-64) => /lib64/libGLESv2.so.2
    libGL.so.1 (libc6,x86-64) => /lib64/libGL.so.1
    libGL.so (libc6,x86-64) => /lib64/libGL.so

but that didn't helped

erzauge commented 6 years ago

I believe so, I can use the x11 terminal from Gnuplot.

jheinen commented 6 years ago

What's the output of:

Could you also try:

p = joinpath(Pkg.dir(ENV["GRDIR"],"lib","libGR.so"))
run(`ldd $p`)
erzauge commented 6 years ago
julia> Pkg.dir("GR")
"/users/student/wuma8935/.julia/v0.6/GR"

julia> ENV["GRDIR"]
"/users/student/wuma8935/.julia/v0.6/GR/src/../deps/gr"

julia> p = joinpath(Pkg.dir(ENV["GRDIR"],"lib","libGR.so"))
"/users/student/wuma8935/.julia/v0.6/GR/deps/gr/lib/libGR.so"

julia> run(`ldd $p`)
ldd: /users/student/wuma8935/.julia/v0.6/GR/deps/gr/lib/libGR.so: Datei oder Verzeichnis nicht gefunden
ERROR: failed process: Process(`ldd /users/student/wuma8935/.julia/v0.6/GR/deps/gr/lib/libGR.so`, ProcessExited(1)) [1]
Stacktrace:
 [1] pipeline_error(::Base.Process) at ./process.jl:682
 [2] run(::Cmd) at ./process.jl:651
jheinen commented 6 years ago

You have an "incomplete" GR installation - no idea why.

Could you please completely rm -rf /users/student/wuma8935/.julia/v0.6/GR and try to re-install GR?

jheinen commented 6 years ago

/users/student/wuma8935/.julia/v0.6/GR/src/../deps/ should then contain:

gr/
gr/lib/
gr/lib/wxplugin.so
gr/lib/libGKS.so
gr/lib/zmqplugin.so
gr/lib/gsplugin.so
gr/lib/qt5plugin.so
gr/lib/libGR3.so
gr/lib/movplugin.so
gr/lib/qtplugin.so
gr/lib/wmfplugin.so
gr/lib/pgfplugin.so
gr/lib/cairoplugin.so
gr/lib/glplugin.so
gr/lib/htmplugin.so
gr/lib/gtkplugin.so
gr/lib/svgplugin.so
gr/lib/figplugin.so
gr/lib/libGR.so
gr/fonts/
gr/fonts/NimbusMonL-BoldObli.afm
gr/fonts/NimbusRomNo9L-ReguItal.pfb
gr/fonts/URWPalladioL-BoldItal.afm
gr/fonts/NimbusSanL-Regu.afm
gr/fonts/NimbusRomNo9L-Medi.afm
gr/fonts/URWBookmanL-Ligh.afm
gr/fonts/CenturySchL-BoldItal.afm
gr/fonts/NimbusSanL-Bold.afm
gr/fonts/NimbusSanL-BoldItal.afm
gr/fonts/CenturySchL-Bold.pfb
gr/fonts/URWBookmanL-DemiBoldItal.afm
gr/fonts/NimbusSanL-BoldItal.pfb
gr/fonts/URWBookmanL-Ligh.pfb
gr/fonts/URWPalladioL-Roma.afm
gr/fonts/NimbusRomNo9L-MediItal.afm
gr/fonts/NimbusSanL-BoldCond.afm
gr/fonts/NimbusRomNo9L-Medi.pfb
gr/fonts/URWGothicL-Demi.afm
gr/fonts/NimbusRomNo9L-MediItal.pfb
gr/fonts/NimbusSanL-BoldCond.pfb
gr/fonts/NimbusSanL-ReguCondItal.pfb
gr/fonts/NimbusMonL-Regu.pfb
gr/fonts/URWPalladioL-Ital.afm
gr/fonts/URWPalladioL-Roma.pfb
gr/fonts/NimbusSanL-BoldCondItal.afm
gr/fonts/NimbusSanL-ReguItal.pfb
gr/fonts/URWBookmanL-DemiBoldItal.pfb
gr/fonts/CenturySchL-Ital.pfb
gr/fonts/gksfont.dat
gr/fonts/NimbusMonL-ReguObli.pfb
gr/fonts/StandardSymL.afm
gr/fonts/NimbusSanL-ReguCondItal.afm
gr/fonts/URWGothicL-DemiObli.afm
gr/fonts/NimbusMonL-BoldObli.pfb
gr/fonts/URWBookmanL-LighItal.pfb
gr/fonts/CenturySchL-Roma.afm
gr/fonts/NimbusRomNo9L-Regu.pfb
gr/fonts/CenturySchL-Bold.afm
gr/fonts/URWBookmanL-DemiBold.afm
gr/fonts/CenturySchL-Roma.pfb
gr/fonts/URWGothicL-Book.afm
gr/fonts/URWGothicL-BookObli.afm
gr/fonts/URWChanceryL-MediItal.afm
gr/fonts/CenturySchL-Ital.afm
gr/fonts/NimbusMonL-Bold.pfb
gr/fonts/URWPalladioL-Ital.pfb
gr/fonts/URWPalladioL-Bold.afm
gr/fonts/NimbusSanL-ReguItal.afm
gr/fonts/URWGothicL-BookObli.pfb
gr/fonts/NimbusSanL-Bold.pfb
gr/fonts/URWPalladioL-Bold.pfb
gr/fonts/NimbusMonL-Regu.afm
gr/fonts/URWGothicL-DemiObli.pfb
gr/fonts/URWPalladioL-BoldItal.pfb
gr/fonts/Dingbats.pfb
gr/fonts/URWChanceryL-MediItal.pfb
gr/fonts/Dingbats.afm
gr/fonts/NimbusMonL-Bold.afm
gr/fonts/NimbusSanL-ReguCond.pfb
gr/fonts/NimbusRomNo9L-Regu.afm
gr/fonts/NimbusMonL-ReguObli.afm
gr/fonts/URWBookmanL-LighItal.afm
gr/fonts/URWGothicL-Demi.pfb
gr/fonts/NimbusSanL-ReguCond.afm
gr/fonts/NimbusSanL-Regu.pfb
gr/fonts/URWBookmanL-DemiBold.pfb
gr/fonts/StandardSymL.pfb
gr/fonts/CenturySchL-BoldItal.pfb
gr/fonts/URWGothicL-Book.pfb
gr/fonts/NimbusSanL-BoldCondItal.pfb
gr/fonts/NimbusRomNo9L-ReguItal.afm
gr/bin/
gr/bin/gksqt
gr/include/
gr/include/gr3.h
gr/include/gr.h
gr/include/gks.h
gr/include/grwidget.h
jheinen commented 6 years ago

... and there must be no other installation in $HOME/gr or /usr/local/gr

erzauge commented 6 years ago

thank you that work