I am using Julia on a Mac laptop. Everything worked fine until yesterday when I want to do some plots I can no longer import the Plots package. When I try to do Using Plots, I receive the following error message:
[ Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] ERROR: LoadError: MethodError: no method matching floatrange(::Type{Float64}, ::Int64, ::Int64, ::Float64, ::Int64) Closest candidates are: floatrange(::Type{T}, ::Integer, ::Integer, ::Integer, ::Integer) where T at twiceprecision.jl:381 floatrange(::AbstractFloat, ::AbstractFloat, ::Real, ::AbstractFloat) at twiceprecision.jl:395 Stacktrace: [1] floatrange(a::Float64, st::Float64, len::Float64, divisor::Float64) @ Base ./twiceprecision.jl:403 …
What I have tried: I have tried the following methods but unfortunately none of them works:
- Tried to do Pkg.update(), Pkg.resolve(), Pkg.gc()
- Tried to first do Pkg.rm(“Plots”) and then Pkg.add(“Plots”). Both commands executed without errors but when I try to import the package again the same error message occurs.
- Tried PkgCleanup · Julia Packages but it doesn’t work.
- Tried all methods mentioned in these two links: MethodError: no method matching floatrange when running histogram. 1.7.0 Win 11 21H2 AMD 5900Hx - #6 by enzomar MethodError: no method matching floatrange when running histogram. 1.7.0 Win 11 21H2 AMD 5900Hx - #6 by enzomar but unfortunately nothing worked.
The links above did mention something about deleting “old manefest/project files” but unfortunately, as someone who is new to Julia, I have no idea what this means, or how to do that. Any suggestions are greatly appreciated.
What Version of plots are you on? Can you show the output of ] st
in the environment in which you’re seeing this error?
Thank you nilshg. It’s version 1.8 as the output of “]”
Thank you Kristoffer. I executed a command “Pkg.Update(“StatsBase”)” and it executed without errors. Here are the messages:
Updating registry at `~/.julia/registries/General.toml`
No Changes to ~/.julia/environments/v1.8/Project.toml
Updating ~/.julia/environments/v1.8/Manifest.toml
⌅ [4fba245c] + ArrayInterface v2.14.17
[01453d9d] ↑ DiffEqDiffTools v0.14.0 ⇒ v1.7.0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use status --outdated -m
Precompiling project…
5 dependencies successfully precompiled in 11 seconds. 222 already precompiled. 1 skipped during auto due to previous errors.
After this, I tried “Using Plots” but am still receiving the same error message.
No, that’s not the output of ]
- ]
just drops you into the Pkg REPL mode, and the @v1.8
just means you are in your default environment. You then have to type st
and press enter to get the versions of all installed packages.
Sorry for the confusion. The versions of packages are below, by running the “st” command at ] environment:
Status ~/.julia/environments/v1.8/Project.toml
[a93c6f00] DataFrames v1.5.0
⌅ [31c24e10] Distributions v0.23.8
⌃ [38e38edf] GLM v1.4.2
[8d5ece8b] GLMNet v0.7.1
⌃ [033835bb] JLD2 v0.4.3
[857edff2] KernelEstimator v0.3.3
⌃ [b4fcebef] Lasso v0.5.2
⌃ [355abbd5] POMDPModels v0.4.9
[a575d7f4] POMDPSolve v0.2.3
[a93abf59] POMDPs v0.9.5
[f3e62ec7] PkgCleanup v0.1.0 https://github.com/giordano/PkgCleanup.jl#main
⌃ [91a5bcdd] Plots v1.35.2
⌃ [3aa3ecc9] QMDP v0.1.6
⌅ [2913bbd2] StatsBase v0.32.2
Info Packages marked with ⌃ and ⌅ have new versions available, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use status --outdated
It does seem StatsBase is outdated in this list. However this is after I carried out Pkg.update(StatsBase). Any suggestion on how to update it to the latest 1.7.0 version?
Your plots is pretty outdated - the current version is 1.38.11. Do add Plots@1.38
in the Pkg REPL to see what’s holding it back.
On a related note, it is not recommended to install all packages in the default environment. You should keep only development dependencies like IJulia, Revise etc. in the default environment and work in project specific environments with only those packages needed for a specific piece of work to minimise these kinds of version conflicts.
1 Like
Thank you! This now works perfectly for me.
And also appreciate your suggestions on default/specific environments. Have been transiting from Matlab to Julia for less than a month so still a lot to learn