Error in loadNamespace(x) : there is no package called ‘JuliaCall’

337 Views Asked by At

I just started to learn Julia in Quarto but when I run the following code in a Julia chunk in Quarto:

---
title: "Julia in Quarto"
editor: visual
format: html
---

```{julia}
# generating vectors
# x-axis
x = 1:10
 
# y-axis
y = rand(10)
 
# simple plotting
plot(x, y)
```

It returns:

Error in loadNamespace(x) : there is no package called ‘JuliaCall’

The error still appears even when adding:

using Pkg
Pkg.add("JuliaCall")

To the code chunk. Does anyone knows how to run the following Julia code in Quarto?


Please note: I use Rstudio

1

There are 1 best solutions below

2
On BEST ANSWER

JuliaCall is an R package. Quarto executes Julia code using the IJulia Jupyter kernel. To use it, specify jupyter: julia_version in the YAML header. A Quarto installation guide is available.

To render Quarto documents that contain julia chunks

  1. start julia
  2. Enter package mode by pressing ].
  3. run Add IJulia
  4. Go back to the REPL (backspace), the default prompt after you start julia
  5. run using IJulia
  6. run notebook(). Use Ctrl+c or quitting julia to stop the Jupyter kernel.

If you don't have Jupyter installed at this point, this will be installed, refer to the above guide for details. This may take a while and prompt some input.

Now you should be able to render a document via the Quarto Cli from a shell and1 RStudio. For example, the following example.qmd should render and print a matrix.

---
title: "Bla"
jupyter: julia-1.8
---
```{julia}
[1 2 3]
```

This may a slow. Refer to the above guide on installing Revise.jl and using Jupyter Cache to speed things up. I personally experience speedup in using VSCode + Quarto extension over RStudio.


If not, the following allows R users to run julia code from within R and RStudio,

  1. in R, use install.package("JuliaCall")
  2. in R, run JuliaCall::julia_setup()

This takes care of some PATH variable and comes with the installJulia optional argument.