# Unable to reproduce Catalyst.jl Example

**URL:** <https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099>\
**Category:** New to Julia\
**Tags:** catalyst\
**Created:** [November 12, 2023, 1:20am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099 "2023-11-12T01:20:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaritm1](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@amaritm1](https://discourse.julialang.org/u/amaritm1)\
**Post date:** [November 12, 2023, 1:20am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/1 "2023-11-12T01:20:05Z")

</div>

I am running Julia 1.9.3 using jupyter notebooks, and cannot reproduce the following example: [Home · Catalyst.jl](https://docs.sciml.ai/Catalyst/stable/). I am simply copying and pasting the code. However, when I graph the reaction network I get the following diagram, which does not match up exactly as the one given in the example. Everything is identical to the diagram produced in the example with the only difference being that the rates of change are labeled. But I don’t know why the diagram produced isn’t identical to the one in the example. I would like to know why this difference is occurring, but the real issue is the following error when trying to define the ODE problem:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/d/3d501b13b32eb073c675948c8903fe411378cac7.png)

From what I understand, I have added and updated all the relevant packages, and jupyter is setup to the best of knowledge. I don’t think there is a scoping issue, because I got the same error when I defined the reaction net and ran defined the ODE in the same cell. I am completely stuck, since this is my first run through numerical ODEs in Julia.

Any thoughts or guidance would be much appreciated.

---

<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:** [November 12, 2023, 1:46am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/2 "2023-11-12T01:46:52Z")

</div>

What version are you using? Can you show `]st`?

---

<div class="post-metadata">

**Author:** ![amaritm1](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@amaritm1](https://discourse.julialang.org/u/amaritm1)\
**Post date:** [November 12, 2023, 1:58am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/3 "2023-11-12T01:58:44Z")

</div>

When I run that command I get: IJulia v1.24.2. I was under the impression that installing Julia 1.9.3 meant that you were using version 1.9.3. Have I not updated the version of Julia that jupyter notebooks is actually looking at?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/1/41a5f694233c71e7e8baf7ccd8a7c2df451b3d7d.png)

---

<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:** [November 12, 2023, 2:26am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/4 "2023-11-12T02:26:25Z")

</div>

How did you install the package? That should show your installed packages if you do it on the right Project.toml.

---

<div class="post-metadata">

**Author:** ![amaritm1](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@amaritm1](https://discourse.julialang.org/u/amaritm1)\
**Post date:** [November 12, 2023, 2:42am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/5 "2023-11-12T02:42:09Z")

</div>

Is this not sufficient to install the packages in Julia? I am under the impression that example in [Home · Catalyst.jl](https://docs.sciml.ai/Catalyst/stable/) is self contained. The only assumption is that I have the correct version of Julia installed and jupyter notebooks is looking at that version. Also a few quick questions about the output of the `]st` command. How do I know if the relationship between the output of `]st` and the version of Julia I have installed is correct? Or are they not related at all? Will installing a version of Julia update that environment appropriately?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/c/bc4f1d2c52fda83ea6c542c05b40254e13624547.png)

---

<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:** [November 12, 2023, 2:48am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/6 "2023-11-12T02:48:37Z")

</div>

Can you do `]st` in the notebook? Or if in the REPL, do it on the same environment as you’re using here.

---

<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:** [November 12, 2023, 2:49am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/7 "2023-11-12T02:49:36Z")

</div>

> [@amaritm1](#):
>
> I am under the impression that example in [Home · Catalyst.jl](https://docs.sciml.ai/Catalyst/stable/) is self contained. The only assumption is that I have the correct version of Julia installed and jupyter notebooks is looking at that version.

 ![Screenshot 2023-11-11 at 9.49.06 PM](https://global.discourse-cdn.com/julialang/original/3X/7/1/71b347fd15ecb6e73eccf0a4224a831f810edfcb.jpeg)

If you look on the bottom left you see the version of Catalyst that the documentation is referring to. If you have a different version of Catalyst then you’d need to update or use the docs for the different version. My running assumption is that you’re on something older like v12 because maybe you didn’t update your registry before installing packages.

---

<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:** [November 12, 2023, 2:56am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/8 "2023-11-12T02:56:08Z")

</div>

And can you please share the full code that you actually ran as text, not a screenshot? I just ran the code just fine:

```julia
using Catalyst, OrdinaryDiffEq
rn = @reaction_network begin
    α, S + I --> 2I
    β, I --> R
end
u0 = [:S => 990.0, :I => 1.0, :R => 0.0]
tspan = (0.0, 250.0)
p = [:α => 0.1/1000, :β => 0.1]
prob = ODEProblem(rn, u0, tspan, p)
sol = solve(prob, Tsit5())

```

gives:

```julia
julia> sol = solve(prob, Tsit5())
retcode: Success
Interpolation: specialized 4th order "free" interpolation
t: 9-element Vector{Float64}:
   0.0
   0.014135066238276477
   0.15548572862104124
   1.5689923524486886
  15.704058590725163
  59.090169376339844
 136.60311536977474
 235.03070390559344
 250.0
u: 9-element Vector{Vector{Float64}}:
 [990.0, 1.0, 0.0]
 [989.9986006393219, 0.9999858640446699, 0.0014134966334038547]
 [989.9846082297721, 0.9998444067138262, 0.015547363514026248]
 [989.8448043450596, 0.998420078473321, 0.1567755764670593]
 [988.4592645215671, 0.9832247249614143, 1.5575107534715067]
 [984.3671574973882, 0.9268543671734841, 5.705988135438275]
 [977.785522472754, 0.7998781032069555, 12.414599424039093]
 [970.9718385037306, 0.6206834123135646, 19.40747808395581]
 [970.0896048802567, 0.5938951320950598, 20.31649998764821]

```

with package versions

```julia
(@v1.10) pkg> st
Status `~/.julia/environments/v1.10/Project.toml`
  [479239e8] Catalyst v13.5.1
  [1dea7af3] OrdinaryDiffEq v6.59.0

```

---

<div class="post-metadata">

**Author:** ![amaritm1](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@amaritm1](https://discourse.julialang.org/u/amaritm1)\
**Post date:** [November 12, 2023, 3:49am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/9 "2023-11-12T03:49:30Z")

</div>

After updating all the packages, when I run the code in the example verbatim directly on the terminal it does work. That means the issue is that jupyter is not looking at the right version of Julia. How do I get those to match up? (I also do not know how to check the package versions that jupyter is looking at. I can see that when I open Julia in the terminal, but not when I am using jupyter notebooks.)

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [November 12, 2023, 6:59am UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/10 "2023-11-12T06:59:01Z")

</div>

IJulia supports the Pkg REPL mode so `] st` will tell you what’s in your current environment. Julia versions can be selected from the menu at the top where you’ll find an orion to change kernels.

---

<div class="post-metadata">

**Author:** ![amaritm1](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@amaritm1](https://discourse.julialang.org/u/amaritm1)\
**Post date:** [November 12, 2023, 4:04pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/11 "2023-11-12T16:04:59Z")

</div>

All of these errors are occurring with the correct version of Julia.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/f/2f9f359af9a3f479b3c1d760b2c81d346d66053e.png) The issue is now that I can reproduce the example in the terminal that opens when I use the Julia app directly, but not when using jupyter notebooks. I ran `] up` and that did update all my packages. Then in the same terminal I ran all the code in the example and it _did_ work. But when I ran `using IJulia notebook()` and ran the same code as the example, again, I got the same error: `"ArgumentError: Any[S(t), I(t), R(t), α(t), β(t)] are missing from the variable map."`. This means the issue is probably with the versions of the packages that jupyter notebooks is looking at, but I don’t know how to make those agree with the versions used in the terminal (which do work).

---

<div class="post-metadata">

**Author:** ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)\
**Post date:** [November 12, 2023, 4:45pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/12 "2023-11-12T16:45:15Z")

</div>

In a Notebook cell can you type and run the following, and then give us the full output you see?

```julia
using Pkg
Pkg.status()

```

---

<div class="post-metadata">

**Author:** ![amaritm1](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@amaritm1](https://discourse.julialang.org/u/amaritm1)\
**Post date:** [November 12, 2023, 5:49pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/13 "2023-11-12T17:49:14Z")

</div>

This is the full output I see:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/b/db4ee331da3f1fddd76992ed99df11ebb1a3574d.png)

---

<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:** [November 12, 2023, 6:09pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/14 "2023-11-12T18:09:16Z")

</div>

Notice you have Catalyst v10, which is where the issue is coming from. PerceptualColorMaps.jl hasn’t been updated in a long time and is likely holding everything back [https://github.com/peterkovesi/PerceptualColourMaps.jl/blob/master/Project.toml](https://github.com/peterkovesi/PerceptualColourMaps.jl/blob/master/Project.toml) . I would remove that package and update.

---

<div class="post-metadata">

**Author:** ![amaritm1](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@amaritm1](https://discourse.julialang.org/u/amaritm1)\
**Post date:** [November 12, 2023, 7:00pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/15 "2023-11-12T19:00:17Z")

</div>

I ran `using Pkg Pkg.rm("Catalyst")` and added it back and the version updated to 12.1.1, but now I am having a different issue where Julia is complaining when pre-compiling Catalyst.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/9/69f9cfcfe68ddfb0b203660d5659fd0134b619b9.png)

---

<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:** [November 12, 2023, 7:05pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/16 "2023-11-12T19:05:20Z")

</div>

I didn’t mean remove Catalyst, I said remove PerceptualColorMaps.jl

---

<div class="post-metadata">

**Author:** ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)\
**Post date:** [November 12, 2023, 8:49pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/17 "2023-11-12T20:49:35Z")

</div>

@amaritm1 Julia packages have to specify their compatibility with packages they depend on. If you have even one package that is very out of date and setup to only declare compatibility with older versions of widely used packages it will block you from being to use newer versions of most actively maintained packages.

As Chris mentioned that seems to be what is going on here. Adding and removing Catalyst won’t fix the issue; you need to remove the older package that is preventing newer versions of so many packages from being installed when you update (notice how many of the packages in your status have a “^” indicating they are not the latest version).

If you remove PerceptualColorMaps as Chris suggested hopefully you will then be able to run `Pkg.update()` and get the newest versions of your remaining packages (note that GraphViz.jl has also not been updated in a long time, but it only has a few dependencies and they aren’t capped, so hopefully it won’t cause issues).

An alternative to all this is to make a new, empty environment, and just add the minimal set of packages you need to it:

```julia
using Pkg
Pkg.add("name_you_want_for_your_environment")
# or Pkg.(; temp = true) if you just want a temp environment
Pkg.add("Catalyst")
Pkg.add("DifferentialEquations")
...
``
```

---

<div class="post-metadata">

**Author:** ![amaritm1](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@amaritm1](https://discourse.julialang.org/u/amaritm1)\
**Post date:** [November 12, 2023, 11:29pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/18 "2023-11-12T23:29:38Z")

</div>

Wow that’s good to know. I will remove that package and give it a try. The minimal environment is also a good suggestion. That one should work because I assume that is what happens when I copy and paste the code into the Julia terminal. However as I was about to remove PerceptualColorMaps jupyter cannot connect to the kernel, and I do not why, because I have made no changes to the environment. I already ran `] build IJulia` and did not see any issues. Are there any other obvious thing to check?

---

<div class="post-metadata">

**Author:** ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)\
**Post date:** [November 13, 2023, 2:49pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/19 "2023-11-13T14:49:51Z")

</div>

Sorry, when I have Jupyter issues I do what you said you did; I restart the Julia REPL, rebuild IJulia, and restart the notebook server. That usually fixes things.

As an alternative, you could try opening your notebook in Visual Studio Code (just make sure to have installed the Julia and Jupyter notebook extensions).

---

<div class="post-metadata">

**Author:** ![amaritm1](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@amaritm1](https://discourse.julialang.org/u/amaritm1)\
**Post date:** [November 13, 2023, 9:26pm UTC](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099/20 "2023-11-13T21:26:15Z")

</div>

I got it to work. Thank you @isaacsas, @nilshg, and @ChrisRackauckas for all your help. I just used a completely fresh environment and it worked. My only remaining question is how did @ChrisRackauckas look at the output of `Pkg.status()` and know that it was `PerceptualColorMaps.jl` was holding everyone back? I see that a lot of packages have newer versions available in that screenshot, but it is not obvious to me why `PerceptualColorMaps.jl` is the culprit. I see in the github link that it has not been updated for about a year. Is that very old by Julia package standards?

[Next page](https://discourse.julialang.org/t/unable-to-reproduce-catalyst-jl-example/106099.md?page=2)
