Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple kernels in same file #135

Closed
knuesel opened this issue Oct 13, 2021 · 4 comments
Closed

Multiple kernels in same file #135

knuesel opened this issue Oct 13, 2021 · 4 comments

Comments

@knuesel
Copy link
Contributor

knuesel commented Oct 13, 2021

It would be nice to support executing several languages in the same file. My use case is that I'm using "panel-tabsets" to show solutions implemented in different languages (e.g. Octave and Python). Currently only one of the tabs can show the result of running of the code.

@jjallaire
Copy link
Collaborator

jjallaire commented Oct 13, 2021

Currently Jupyter kernels are single-language. One workaround is cell magics which allow embedding other languages within the main parent kernel (e.g. see this, which I'm not sure is still available/maintained: https://notebook.community/OSGeo-live/CesiumWidget/GSOC/notebooks/ipython/examples/Builtin%20Extensions/Octave%20Magic)

@knuesel
Copy link
Contributor Author

knuesel commented Oct 13, 2021

Interesting! it seems to be maintained still, now part of oct2py and documented at https://oct2py.readthedocs.io/en/latest/source/examples.html . I made a quick test, it was easy to get working. Though this is limited to Python+Octave combinations (I also have Julia code to show in another tab).

I rather had in mind something like splitting the document in several notebooks (one per language) and gathering the results for the final output. But maybe this doesn't fit with the way quarto works...

@baggiponte
Copy link

How does R work? Can't you mix Jupyter and Python code chunks in .Rmd files?

@jmbuhr
Copy link
Contributor

jmbuhr commented Jan 23, 2022

Yes, R can do that through the knitr package, which calls multiple language engines and can also mix R and python code through the reticulate package. You can set the quarto engine to be knitr and should be able to use R and python in the same document: https://quarto.org/docs/computations/running-code.html#engine-binding

Thanks to reticulate you can even use variables from R in your python chunks and the other way around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants