Problem in solve() DifferentialEquations. None algorithm define

Hi,

I am new to Julia. I am trying to integrate an ODE. It works in my colleagues PC but not in mine. It looks like the package has not been loaded but I did it at the beginning of the script. I have tried with many solvers and all gives the same error:
ERROR: UndefVarError: `Vern7` not defined

The code is:

``````# Load pkgs and remove data -----------------------------------------------------
using DifferentialEquations
using DataFrames
using CSV
using Plots
using Shapefile
using PlotShapefiles
import GeoDataFrames as GDF
using LinearAlgebra
using ODE
#using LSODA
#using Interpolations
#using OrdinaryDiffEq

# For after do a separate file
#include("~/albo_mobility/code/Hanski/ode_model.jl") # Code with ODE model

# Set const parameters
# Set constants to estimate to random variables to create fake observed data
e = rand(Float64) * 0.01  # extinction constant (estimate)
c_d = rand(Float64) * 0.00000001  # colonization constant (estimate)
c_h = rand(Float64) * 0.001  # colonization constant (estimate)
xi = rand(Float64)  # dispersal scaling parameter (estimate)

println(e)

# These variables might be estimated in the future
m_c = 0.001 # probability of mosquito in a car
alpha = 1 / 200 # average natural dispersal distance

...

# Set parameters
t0=0
tf=1824
tspan = (t0, tf)
t_vect=1:tf

function fun(du, u, p, t)
mat = exp.(-alpha*d_1)
mat[diagind(mat)] .= 0 # Set to zero diagonal of distance
Cd = c_d.*mat*u # Natural dispersal
Ch = c_h.*(m_c*eta)*u # Human mobility
du.= (xi .* Cd + (1 - xi) .* Ch) .* (1 .- u) - e .* u
end

p = 0 # We have to give a value
prob = ODEProblem(fun, pop_init, tspan, p)
rtol=1e-10
sol = DifferentialEquations.solve(prob,Tsits5()) # , maxiters=1e6) #reltol=1e-8) #, #
sol = OrdinaryDiffEq.solve(prob,Tsits5()) # , maxiters=1e6) #reltol=1e-8) #, #
sol = solve(prob,  Vern7()) # , maxiters=1e6) #reltol=1e-8) #, #
``````

What Julia version and how did you install it?

Hi Chris,

I am using Julia 1.10.2. I install following the info in the website:

It says to run in the terminal:

``````curl -fsSL https://install.julialang.org | sh
``````

and I use Visual code to run it. I am working in Ubuntu 20.04.4.

What is the output of:

``````using Pkg
Pkg.status()
``````

?

It is solved. Thanks for the help

Do you know how it was solved? This might help othersβ¦

I do not know. Now i have the problem that each time I open visual code I have to install DifferentialEquations package. Otherwise I get the error: ERROR: LoadError: UndefVarError: `SciMLBase`not defined. And now when i run the ODEProblem(fun, op,β¦) if give me the error that its not defined aswellβ¦

What could be the reason?

You must be sure that the correct environment is opened. In VSCode,
at the bottom you can see the the active environment like:

``````Julia env: KiteControllers.jl
``````

if the environment (Project.toml) in the folder `KiteControllers.jl` is active.

If you click on the name of the environment you get a dialog that allows you to activate a different environment.

If DifferentialEquations.jl is part of your active project, then you can use it.

It says Julia env:v1.10 So where the julia is intalled. Should I create another enviroment? I always using this

Always use a separate environment per project.
Like:

``````mkdir myproject
cd myproject
julia --project="."
``````

And then in Julia:

``````using Pkg
# ... and all the other packages you need for this specific project
``````

This avoids conflicts if you need the newest version of a package in project A, but that conflicts with another package that you need in project Bβ¦

After you created, start Julia like this:

``````julia --project
``````

If you open a folder in VSCode it activates the project (Project.toml) that is present in that folder automatically.

Perfect, thanks a lot. I have created a env in the git hub repo.

1 Like

I have used the enviroment as you told me. Today I open visual code in the environment that I have created and yesterday everything works but today I get the same problem with the using DifferentialEquations :

DifferentialEquations
Info Given DifferentialEquations was explicitly requested, output will be shown live
WARNING: Method definition (::Type{Base.MPFR.BigFloat})(Base.Irrational{:invsqrt2Ο}) in module IrrationalConstants at irrationals.jl:223 overwritten in module StatsFuns on the same line (check for duplicate calls to `include`).
ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.
? Distributions
? DiffEqNoiseProcess
? DiffEqFinancial
? StochasticDiffEq
? MultiScaleArrays
? DifferentialEquations
0 dependencies successfully precompiled in 34 seconds. 131 already precompiled.
6 dependencies failed but may be precompilable after restarting julia
6 dependencies had output during precompilation:
β StochasticDiffEq
β - You may have a partially installed environment. Try `Pkg.instantiate()`
β to ensure all packages in the environment are installed.
β - Or, if you have AdaptStaticArraysCoreExt checked out for development and have
β environmentβs manifest file, try `Pkg.resolve()`.
β - Otherwise you may need to report an issue with AdaptStaticArraysCoreExt
β Stacktrace:
β [1] macro expansion
β [2] macro expansion
β @ ./lock.jl:267 [inlined]
β [3] __require(into::Module, mod::Symbol)
β [4] #invoke_in_world#3
β @ ./essentials.jl:926 [inlined]
β [5] invoke_in_world
β @ ./essentials.jl:923 [inlined]
β [6] require(into::Module, mod::Symbol)
β [7] include
β @ ./Base.jl:495 [inlined]
β [9] top-level scope
β @ stdin:3
β in expression starting at stdin:3
β β Error: Error during loading of extension AdaptStaticArraysExt of Adapt, use `Base.retry_load_extensions()` to retry.
β β exception =
β β 1-element ExceptionStack:
β β Stacktrace:
β β [1] error(s::String)
β β @ Base ./error.jl:35
β β [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
β β [3] compilecache
β β [4] (::Base.var"#968#969"{Base.PkgId})()
β β [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
β β @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:93
β β [6] #mkpidlock#6
β β @ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:88 [inlined]
β β [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
β β @ FileWatching.Pidfile ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:111
β β [8] #invokelatest#2
β β @ ./essentials.jl:894 [inlined]
β β [9] invokelatest
β β @ ./essentials.jl:889 [inlined]
β β [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
β β [11] maybe_cachefile_lock
β β [12] _require(pkg::Base.PkgId, env::Nothing)
β β [13] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
β β [14] #invoke_in_world#3
β β @ ./essentials.jl:926 [inlined]
β β [15] invoke_in_world
β β @ ./essentials.jl:923 [inlined]
β β [16] _require_prelocked
β β [17] _require_prelocked
β β [18] run_extension_callbacks(extid::Base.ExtensionId)
ERROR: UndefVarError: `ODEProblem` not defined