# LoadError: UndefVarError: Penalty not defined

**URL:** <https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046>\
**Category:** Optimization (Mathematical)\
**Tags:** diffeq\
**Created:** [April 22, 2020, 9:43pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046 "2020-04-22T21:43:58Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![DKad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkad/32/203663_2.png) [@DKad](https://discourse.julialang.org/u/DKad)\
**Post date:** [April 22, 2020, 9:43pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/1 "2020-04-22T21:43:58Z")

</div>

Hello, I want to adapt parameters of a differential equation to available data on a computer with julia 1.4.1 on a linux system. julia 1.4.0 has the same problem.

Running  
using DifferentialEquations  
using Plots

is o.K. but using DiffEqParamEstim results into an error: I start the REPL with julia and then input

using DiffEqParamEstim

with results:  
[Info: Precompiling DiffEqParamEstim [1130ab10-4a5a-5621-a13d-e4788d82bd4c]  
WARNING: could not import LearnBase.prox into PenaltyFunctions  
WARNING: could not import LearnBase.prox! into PenaltyFunctions  
WARNING: could not import LearnBase.addgrad! into PenaltyFunctions  
WARNING: could not import LearnBase.scaled into PenaltyFunctions  
ERROR: LoadError: UndefVarError: Penalty not defined  
Stacktrace:  
[1] top-level scope at /home/ad08/.julia/packages/PenaltyFunctions/6Cxmi/src/PenaltyFunctions.jl:37  
[2] include(::Module, ::String) at ./Base.jl:377  
[3] top-level scope at none:2  
[4] eval at ./boot.jl:331 [inlined]  
[5] eval(::Expr) at ./client.jl:449  
[6] top-level scope at ./none:3  
in expression starting at /home/ad08/.julia/packages/PenaltyFunctions/6Cxmi/src/PenaltyFunctions.jl:37  
ERROR: LoadError: Failed to precompile PenaltyFunctions [06bb1623-fdd5-5ca2-a01c-88eae3ea319e] to /home/ad08/.julia/compiled/v1.4/PenaltyFunctions/RxfJh\_O8MUa.ji.  
Stacktrace:  
[1] error(::String) at ./error.jl:33  
[2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272  
[3] \_require(::Base.PkgId) at ./loading.jl:1029  
[4] require(::Base.PkgId) at ./loading.jl:927  
[5] require(::Module, ::Symbol) at ./loading.jl:922  
[6] include(::Module, ::String) at ./Base.jl:377  
[7] top-level scope at none:2  
[8] eval at ./boot.jl:331 [inlined]  
[9] eval(::Expr) at ./client.jl:449  
[10] top-level scope at ./none:3  
in expression starting at /home/ad08/.julia/packages/DiffEqParamEstim/vV8rW/src/DiffEqParamEstim.jl:2  
ERROR: Failed to precompile DiffEqParamEstim [1130ab10-4a5a-5621-a13d-e4788d82bd4c] to /home/ad08/.julia/compiled/v1.4/DiffEqParamEstim/nWq0E\_O8MUa.ji.  
Stacktrace:  
[1] error(::String) at ./error.jl:33  
[2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272  
[3] \_require(::Base.PkgId) at ./loading.jl:1029  
[4] require(::Base.PkgId) at ./loading.jl:927  
[5] require(::Module, ::Symbol) at ./loading.jl:922

I have no idea what is wrong. Shall I downgrade to julia-0.7.0 ? REQUIRE in PenaltyFunctions includes the row  
julia 0.7-beta.

---

<div class="post-metadata">

**Author:** ![joshday](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joshday/32/368_2.png) [@joshday](https://discourse.julialang.org/u/joshday)\
**Post date:** [April 23, 2020, 12:02pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/2 "2020-04-23T12:02:13Z")

</div>

I would first try a `Pkg.update()`. The most recent version of PenaltyFunctions doesn’t have a REQUIRE file (replaced with Project.toml).

---

<div class="post-metadata">

**Author:** ![DKad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkad/32/203663_2.png) [@DKad](https://discourse.julialang.org/u/DKad)\
**Post date:** [April 23, 2020, 12:25pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/3 "2020-04-23T12:25:45Z")

</div>

Thank you, but Pkg.update has no measurable effect. All seems to find, but PenaltyFunctions is unchanged. Do you know, where I can find a new version of PenaltyFunctions?

---

<div class="post-metadata">

**Author:** ![joshday](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joshday/32/368_2.png) [@joshday](https://discourse.julialang.org/u/joshday)\
**Post date:** [April 23, 2020, 3:14pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/4 "2020-04-23T15:14:23Z")

</div>

Can you share your `Pkg.status()`?

---

<div class="post-metadata">

**Author:** ![DKad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkad/32/203663_2.png) [@DKad](https://discourse.julialang.org/u/DKad)\
**Post date:** [April 23, 2020, 3:22pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/5 "2020-04-23T15:22:40Z")

</div>

My Pkg.status() is:  
julia\> Pkg.status()  
Status `~/.julia/environments/v1.4/Project.toml`  
[15425d4b] BitFloats v0.0.3  
[a134a8b2] BlackBoxOptim v0.5.0  
[159f3aea] Cairo v1.0.3  
[5ae59095] Colors v0.12.0  
[1130ab10] DiffEqParamEstim v1.13.0  
[0c46a032] DifferentialEquations v6.13.0  
[7f8f8fb0] LearnBase v0.4.0  
[429524aa] Optim v0.20.6  
[06bb1623] PenaltyFunctions v0.1.2  
[91a5bcdd] Plots v0.29.9  
[731186ca] RecursiveArrayTools v2.3.1  
[276daf66] SpecialFunctions v0.10.0

---

<div class="post-metadata">

**Author:** ![joshday](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joshday/32/368_2.png) [@joshday](https://discourse.julialang.org/u/joshday)\
**Post date:** [April 23, 2020, 4:49pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/6 "2020-04-23T16:49:58Z")

</div>

The current release of PenaltyFunctions is 0.2.1. I don’t see any packages there that would be holding it back from upgrading, so I’m not sure what’s going on.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [April 23, 2020, 5:27pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/7 "2020-04-23T17:27:54Z")

</div>

What happens if you do

`]add PenaltyFunctions@0.2.1`

?

---

<div class="post-metadata">

**Author:** ![DKad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkad/32/203663_2.png) [@DKad](https://discourse.julialang.org/u/DKad)\
**Post date:** [April 23, 2020, 5:39pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/8 "2020-04-23T17:39:08Z")

</div>

@dpsanders  
Maybe the result is more informative:

(@v1.4) pkg\> add PenaltyFunctions@0.2.1  
Updating registry at `~/.julia/registries/General`  
Updating git-repo `https://github.com/JuliaRegistries/General.git`  
Resolving package versions…  
ERROR: Unsatisfiable requirements detected for package DiffEqParamEstim [1130ab10]:  
DiffEqParamEstim [1130ab10] log:  
├─possible versions are: [1.2.0, 1.3.0-1.3.1, 1.4.0, 1.5.0-1.5.1, 1.6.0, 1.7.1, 1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0] or uninstalled  
├─restricted to versions \* by an explicit requirement, leaving only versions [1.2.0, 1.3.0-1.3.1, 1.4.0, 1.5.0-1.5.1, 1.6.0, 1.7.1, 1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0]  
└─restricted by compatibility requirements with PenaltyFunctions [06bb1623] to versions: uninstalled — no versions left  
└─PenaltyFunctions [06bb1623] log:  
├─possible versions are: [0.1.0-0.1.2, 0.2.0-0.2.1] or uninstalled  
└─restricted to versions 0.2.1 by an explicit requirement, leaving only versions 0.2.1

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [April 23, 2020, 7:43pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/9 "2020-04-23T19:43:12Z")

</div>

I think this is telling us what the problem is, but I’m not skilled enough at reading these outputs to know what it is.

An alternative idea is to create a new directory and then inside that directory run Julia and do

] activate myproject

That will create a new empty project that is independent. Then try adding there the packages that you need.

---

<div class="post-metadata">

**Author:** ![brunopjacob](https://avatars.discourse-cdn.com/v4/letter/b/41988e/32.png) [@brunopjacob](https://discourse.julialang.org/u/brunopjacob)\
**Post date:** [April 24, 2020, 12:55am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/10 "2020-04-24T00:55:52Z")

</div>

I’m having the exact same problem… no luck downgrading DifferentialEquations yet 😕

(EDIT) It seems that the problem is in the LearnBase package… try this downgrade

]add LearnBase@0.3

it worked for me!

---

<div class="post-metadata">

**Author:** ![DKad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkad/32/203663_2.png) [@DKad](https://discourse.julialang.org/u/DKad)\
**Post date:** [April 24, 2020, 6:23am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/11 "2020-04-24T06:23:32Z")

</div>

> [@DKad](#):
>
> PenaltyFunctions@0.2.1

@brunopjacob  
Unfortunately it doesn’t work for me. I shall try to generate my .julia directory completely new.  
Many thanks.

---

<div class="post-metadata">

**Author:** ![DKad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkad/32/203663_2.png) [@DKad](https://discourse.julialang.org/u/DKad)\
**Post date:** [April 24, 2020, 9:14am UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/12 "2020-04-24T09:14:16Z")

</div>

@brunopjacob  
My last reply is imprecise. I still cannot upgrade PenaltyFunctions to v.0.2.1. But my original program is running now.  
I think that the problem with Learnbase is not solved, I don’t know if I need it anymore, but for the moment I can do my work.  
Many thanks again.

---

<div class="post-metadata">

**Author:** ![DKad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkad/32/203663_2.png) [@DKad](https://discourse.julialang.org/u/DKad)\
**Post date:** [April 24, 2020, 1:27pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/13 "2020-04-24T13:27:14Z")

</div>

Maybe the problem is that

]add DiffEqParamEstim

downgrades PenaltyFunctions. To resolve the problem I started with an empty local .julia directory and got the following output for adding some packages:  
After  
add DifferentialEquations  
add Plots  
add LinearAlgebra

I added:

(@v1.4) pkg\> add PenaltyFunctions  
Resolving package versions…  
Installed PenaltyFunctions ─ v0.2.1  
Installed LearnBase ──────── v0.4.0  
Updating `~/.julia/environments/v1.4/Project.toml`  
[06bb1623] + PenaltyFunctions v0.2.1  
Updating `~/.julia/environments/v1.4/Manifest.toml`  
[7f8f8fb0] + LearnBase v0.4.0  
[06bb1623] + PenaltyFunctions v0.2.1

@v1.4) pkg\> add DiffEqParamEstim  
Resolving package versions…  
Installed MKL\_jll ──────────────── v2019.0.117+2  
Installed PenaltyFunctions ─────── v0.1.2  
Installed QuadGK ───────────────── v2.3.1  
Installed OptimBase ────────────── v2.0.1  
Installed Arpack ───────────────── v0.4.0  
Installed DiffEqParamEstim ─────── v1.13.0  
Installed Rmath\_jll ────────────── v0.2.2+0  
Installed Distributions ────────── v0.22.6  
Installed DiffEqSensitivity ────── v6.13.0  
Installed ReverseDiff ──────────── v1.2.0  
Installed Tracker ──────────────── v0.2.6  
Installed Arpack\_jll ───────────── v3.5.0+3  
Installed FFTW ─────────────────── v1.2.0  
Installed Sobol ────────────────── v1.3.0  
Installed IntelOpenMP\_jll ──────── v2018.0.3+0  
Installed QuasiMonteCarlo ──────── v0.2.0  
Installed FFTW\_jll ─────────────── v3.3.9+5  
Installed Calculus ─────────────── v0.5.1  
Installed StatsFuns ────────────── v0.8.0  
Installed Rmath ────────────────── v0.6.1  
Installed LsqFit ───────────────── v0.10.0  
Installed PDMats ───────────────── v0.9.12  
Installed Dierckx ──────────────── v0.4.1  
Installed StatsBase ────────────── v0.32.2  
Installed Zygote ───────────────── v0.4.16  
Installed AbstractFFTs ─────────── v0.5.0  
Installed NNlib ────────────────── v0.6.6  
Installed IRTools ──────────────── v0.3.2  
Installed LatinHypercubeSampling ─ v1.6.4  
Downloading artifact: Rmath  
######################################################################## 100,0%##O=# Downloading artifact: Arpack  
######################################################################## 100,0%##O=# Downloading artifact: FFTW  
######################################################################## 100,0%##O=# Downloading artifact: IntelOpenMP  
######################################################################## 100,0%##O=# Updating `~/.julia/environments/v1.4/Project.toml`  
[1130ab10] + DiffEqParamEstim v1.13.0  
[06bb1623] ↓ PenaltyFunctions v0.2.1 ⇒ v0.1.2  
Updating `~/.julia/environments/v1.4/Manifest.toml`  
[621f4979] + AbstractFFTs v0.5.0  
[7d9fca2a] + Arpack v0.4.0  
[68821587] + Arpack\_jll v3.5.0+3  
[49dc2e85] + Calculus v0.5.1  
[39dd38d3] + Dierckx v0.4.1  
[1130ab10] + DiffEqParamEstim v1.13.0  
[41bf760c] + DiffEqSensitivity v6.13.0  
[31c24e10] + Distributions v0.22.6  
[7a1cc6ca] + FFTW v1.2.0  
[f5851436] + FFTW\_jll v3.3.9+5  
[7869d1d1] + IRTools v0.3.2  
[1d5cc7b8] + IntelOpenMP\_jll v2018.0.3+0  
[a5e1c1ea] + LatinHypercubeSampling v1.6.4  
[2fda8390] + LsqFit v0.10.0  
[856f044c] + MKL\_jll v2019.0.117+2  
[872c559c] + NNlib v0.6.6  
[87e2bd06] + OptimBase v2.0.1  
[90014a1f] + PDMats v0.9.12  
[06bb1623] ↓ PenaltyFunctions v0.2.1 ⇒ v0.1.2  
[1fd47b50] + QuadGK v2.3.1  
[8a4e6c94] + QuasiMonteCarlo v0.2.0  
[37e2e3b7] + ReverseDiff v1.2.0  
[79098fc4] + Rmath v0.6.1  
[f50d1b31] + Rmath\_jll v0.2.2+0  
[ed01d8cd] + Sobol v1.3.0  
[2913bbd2] ↓ StatsBase v0.33.0 ⇒ v0.32.2  
[4c63d2b9] + StatsFuns v0.8.0  
[9f7883ad] + Tracker v0.2.6  
[e88e6eb3] + Zygote v0.4.16  
Building FFTW ───→ `~/.julia/packages/FFTW/qqcBj/deps/build.log`  
Building Dierckx → `~/.julia/packages/Dierckx/9SY4A/deps/build.log`  
Building NNlib ──→ `~/.julia/packages/NNlib/FAI3o/deps/build.log`

with the result that PenaltyFunctions and StatsBase were downgraded.

I don’t know if there is a workaround, I shall use my old .julia directory, which at least works.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 24, 2020, 2:30pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/14 "2020-04-24T14:30:16Z")

</div>

> [@DKad](#):
>
> Building NNlib ──→ `~/.julia/packages/NNlib/FAI3o/deps/build.log`
> 
> with the result that PenaltyFunctions and StatsBase were downgraded.
> 
> I don’t know if there is a workaround, I shall use my old .julia directory, which at least works.

Wait 1 hour and then update.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 24, 2020, 6:19pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/15 "2020-04-24T18:19:56Z")

</div>

update

---

<div class="post-metadata">

**Author:** ![DKad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkad/32/203663_2.png) [@DKad](https://discourse.julialang.org/u/DKad)\
**Post date:** [April 24, 2020, 9:27pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/16 "2020-04-24T21:27:37Z")

</div>

I just updated.

> using DiffEqParamEstim

now seems to be o.k. I only got the following warnings. Don’t know if they are relevant.  
julia\> using DiffEqParamEstim  
[Info: Precompiling DiffEqParamEstim [1130ab10-4a5a-5621-a13d-e4788d82bd4c]  
┌ Warning: `lgamma(x::Real)` is deprecated, use `(logabsgamma(x))[1]` instead.  
│ caller = lstirling\_asym(::BigFloat) at misc.jl:56  
└ @ StatsFuns ~/.julia/packages/StatsFuns/2QE7p/src/misc.jl:56  
WARNING: could not import LearnBase.prox into PenaltyFunctions  
WARNING: could not import LearnBase.prox! into PenaltyFunctions  
WARNING: could not import LearnBase.addgrad! into PenaltyFunctions  
WARNING: could not import LearnBase.scaled into PenaltyFunctions

My status now is:  
[a134a8b2] BlackBoxOptim v0.5.0  
[1130ab10] DiffEqParamEstim v1.14.0  
[0c46a032] DifferentialEquations v6.13.0  
[7f8f8fb0] LearnBase v0.4.0  
[429524aa] Optim v0.20.6  
[06bb1623] PenaltyFunctions v0.2.1  
[91a5bcdd] Plots v1.1.0  
[731186ca] RecursiveArrayTools v2.3.1  
[37e2e46d] LinearAlgebra

Thank you for your work.

---

<div class="post-metadata">

**Author:** ![DKad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dkad/32/203663_2.png) [@DKad](https://discourse.julialang.org/u/DKad)\
**Post date:** [April 24, 2020, 9:58pm UTC](https://discourse.julialang.org/t/loaderror-undefvarerror-penalty-not-defined/38046/17 "2020-04-24T21:58:37Z")

</div>

Short remark: The warnings concerning LearnBase now have disappeared. I don’t know why.
