# Method Error: No method Matching ZeroTangent()

**URL:** <https://discourse.julialang.org/t/method-error-no-method-matching-zerotangent/109913>\
**Category:** Optimization (Mathematical)\
**Tags:** autodiff\
**Created:** [February 8, 2024, 8:53am UTC](https://discourse.julialang.org/t/method-error-no-method-matching-zerotangent/109913 "2024-02-08T08:53:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdas123](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdas123/32/32142_2.png) [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Post date:** [February 8, 2024, 8:53am UTC](https://discourse.julialang.org/t/method-error-no-method-matching-zerotangent/109913/1 "2024-02-08T08:53:11Z")

</div>

Here is the dummy Python code that is calling the Julia script (julia.jl)

```julia
import julia
julia.install()
from julia.api import Julia
julia.install
jl = Julia(compiled_modules=False)
from julia import Main

import numpy as np
x0 = np.ones(5)
Main.x0 = x0

jl.eval('include("julia.jl")')

result = jl.eval("optimization(x0)")

```

Here is the julia script (julia.jl)

```julia
import Pkg
Pkg.add("NPZ")
Pkg.add("DelimitedFiles")
Pkg.add("SharedArrays")
Pkg.add("BenchmarkTools")
Pkg.add("Statistics")
Pkg.add("DataFrames")
Pkg.add("AbstractDifferentiation")
Pkg.add("ReverseDiff")
Pkg.add("Nonconvex")
Pkg.add("ChainRulesCore")
Pkg.add("ChainRules")
using DelimitedFiles, NPZ, SharedArrays, BenchmarkTools, Statistics, DataFrames, ChainRulesCore,ChainRules

using AbstractDifferentiation, ReverseDiff
backend = AbstractDifferentiation.ReverseDiffBackend()
using Nonconvex
Nonconvex.@load NLopt

function calc_sse(x0)
    
    return sum(x0*2-(x0).^(0.5))
end
    
obj = Nonconvex.NonconvexCore.CountingFunction(calc_sse)

function optimization(x0)
    model = Model(obj)
    addvar!(model, zeros(5),zeros(5).+100, init=x0)
    alg = NLoptAlg(:LD_LBFGS)
    options = NLoptOptions(ftol_rel = 1e-3)
    ad_model = abstractdiffy(model,backend)
    result = optimize(ad_model, alg, x0, options = options)
    return result
    
end

```

Here is the error:

```julia
---------------------------------------------------------------------------
JuliaError Traceback (most recent call last)
Cell In[9], line 1
----> 1 result = jl.eval("optimization(x0)")

File ~/work/rmine-py3/lib/python3.10/site-packages/julia/core.py:633, in Julia.eval(self, src)
    631 if src is None:
    632 return None
--> 633 ans = self._call(src)
    634 if not ans:
    635 return None

File ~/work/rmine-py3/lib/python3.10/site-packages/julia/core.py:561, in Julia._call(self, src)
    559 # logger.debug("_call(%s)", src)
    560 ans = self.api.jl_eval_string(src.encode('utf-8'))
--> 561 self.check_exception(src)
    563 return ans

File ~/work/rmine-py3/lib/python3.10/site-packages/julia/core.py:615, in Julia.check_exception(self, src)
    613 else:
    614 exception = sprint(showerror, self._as_pyobj(res))
--> 615 raise JuliaError(u'Exception \'{}\' occurred while calling julia code:\n{}'
    616 .format(exception, src))

JuliaError: Exception 'MethodError: no method matching ZeroTangent()
The applicable method may be too new: running in world age 43436, while current world is 115507.

Closest candidates are:
  ZeroTangent() (method too new to be called from this world context.)
   @ ChainRulesCore ~/.julia/packages/ChainRulesCore/PvTbU/src/tangent_types/abstract_zero.jl:57
' occurred while calling julia code:
optimization(x0)

```

Here are the versions of my packages:

```julia
(@v1.10) pkg> status
Status `~/.julia/environments/v1.10/Project.toml`
⌅ [c29ec348] AbstractDifferentiation v0.4.4
  [6e4b80f9] BenchmarkTools v1.4.0
  [d360d2e6] ChainRulesCore v1.21.0
  [a93c6f00] DataFrames v1.6.1
  [8bb1440f] DelimitedFiles v1.9.1
  [7073ff75] IJulia v1.24.2
  [15e1cf62] NPZ v0.4.3
  [01bcebdf] Nonconvex v2.1.3
  [b43a31b8] NonconvexNLopt v0.1.8
  [438e738f] PyCall v1.96.4
  [37e2e3b7] ReverseDiff v1.15.1
  [770da0de] UpdateJulia v0.4.4
  [1a1011a3] SharedArrays
  [10745b16] Statistics v1.10.0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated`

```

---

<div class="post-metadata">

**Author:** ![bdas123](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdas123/32/32142_2.png) [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Post date:** [February 8, 2024, 4:27pm UTC](https://discourse.julialang.org/t/method-error-no-method-matching-zerotangent/109913/2 "2024-02-08T16:27:34Z")

</div>

I’m using Nonconvex.jl and PyCall.jl
