Grisu not defined - Julia

Viewed 704

I have just started to use Julia a few days back. While trying to plot, I am getting the following error:

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

ERROR:

UndefVarError: Grisu not defined

Stacktrace:
  [1] getproperty
    @ .\Base.jl:26 [inlined]
  [2] plain_precision_heuristic(xs::Vector{Float64})
    @ Showoff C:\Users\Administrator\.julia\packages\Showoff\RaPxi\src\Showoff.jl:84
  [3] showoff(xs::Vector{Float64}, style::Symbol)
    @ Showoff C:\Users\Administrator\.julia\packages\Showoff\RaPxi\src\Showoff.jl:117
  [4] optimal_ticks_and_labels(sp::Plots.Subplot{Plots.GRBackend}, axis::Plots.Axis, ticks::Nothing)
    @ Plots C:\Users\Administrator\.julia\packages\Plots\5srrj\src\axes.jl:187
  [5] optimal_ticks_and_labels
    @ C:\Users\Administrator\.julia\packages\Plots\5srrj\src\axes.jl:128 [inlined]
  [6] get_ticks(sp::Plots.Subplot{Plots.GRBackend}, axis::Plots.Axis)
    @ Plots C:\Users\Administrator\.julia\packages\Plots\5srrj\src\axes.jl:238
  [7] _update_min_padding!(sp::Plots.Subplot{Plots.GRBackend})
    @ Plots C:\Users\Administrator\.julia\packages\Plots\5srrj\src\backends\gr.jl:890
  [8] iterate
    @ .\generator.jl:47 [inlined]
  [9] _collect(c::Matrix{AbstractLayout}, itr::Base.Generator{Matrix{AbstractLayout}, 
typeof(Plots._update_min_padding!)}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{2})
    @ Base .\array.jl:691
 [10] collect_similar
    @ .\array.jl:606 [inlined]
 [11] map
    @ .\abstractarray.jl:2294 [inlined]
 [12] _update_min_padding!(layout::Plots.GridLayout)
    @ Plots C:\Users\Administrator\.julia\packages\Plots\5srrj\src\layouts.jl:310
 [13] prepare_output(plt::Plots.Plot{Plots.GRBackend})
    @ Plots C:\Users\Administrator\.julia\packages\Plots\5srrj\src\plot.jl:184
 [14] show(io::Base64.Base64EncodePipe, m::MIME{Symbol("image/png")}, 
plt::Plots.Plot{Plots.GRBackend})
    @ Plots C:\Users\Administrator\.julia\packages\Plots\5srrj\src\output.jl:214
 [15] base64encode(::Function, ::MIME{Symbol("image/png")}, ::Vararg{Any, N} where N; 
context::Nothing)
    @ Base64 
C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Base64\src\encode.jl:209
 [16] base64encode
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Base64\src\encode.jl:206 
[inlined]
 [17] _ijulia_display_dict(plt::Plots.Plot{Plots.GRBackend})
    @ Plots C:\Users\Administrator\.julia\packages\Plots\5srrj\src\ijulia.jl:50
 [18] display_dict(plt::Plots.Plot{Plots.GRBackend})
    @ Plots C:\Users\Administrator\.julia\packages\Plots\5srrj\src\init.jl:81
 [19] #invokelatest#2
    @ .\essentials.jl:708 [inlined]
 [20] invokelatest
    @ .\essentials.jl:706 [inlined]
 [21] execute_request(socket::ZMQ.Socket, msg::IJulia.Msg)
    @ IJulia C:\Users\Administrator\.julia\packages\IJulia\e8kqU\src\execute_request.jl:112
 [22] #invokelatest#2
    @ .\essentials.jl:708 [inlined]
 [23] invokelatest
    @ .\essentials.jl:706 [inlined]
 [24] eventloop(socket::ZMQ.Socket)
    @ IJulia C:\Users\Administrator\.julia\packages\IJulia\e8kqU\src\eventloop.jl:8
 [25] (::IJulia.var"#15#18")()
    @ IJulia .\task.jl:411

Googles it for a few hours. Saw some similar queries but couldn't find a satisfactory solution. Have got both Plot and Grisu packages installed.

2 Answers

Following up on some of the conversation in the comments, the correct steps to resolve this would be:

# Type "]" to enter the package manager and then 

remove plots

add plots

which should resolve this issue.

apparently Grisu was removed from Julia base after Julia 1.6. However, some older packages might still refer to it, so you need to add the now stand-alone Grisu package if you need to use older package versions.

https://juliahub.com/ui/Packages/Grisu/T2ZVU

Pkg.add("Grisu")

if isdefined(Base, :Grisu)
    import Base.Grisu
else
    import Grisu
end
Related