quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.62k stars 296 forks source link

`ojs_define()` in python jupyter notebook error `'ojs_define' is not defined` VScode + Jupyter + Python + Revealjs #3018

Open rleyvasal opened 1 year ago

rleyvasal commented 1 year ago

Bug description

Os: Ubuntu 22.04 VScode: 1.72.2 Quarto: 1.1.251 Quarto VScode extension: v1.51.0

I am following the example in the quarto docs to bring a pandas dataframe to OJS in Jupyter notebook but I get error 'ojs_define' is not defined

ojs_definepng

ojs_jupyter.zip

Checklist

cscheid commented 1 year ago

Ah, this is an interesting one. The issue here is that when we execute the python code ourselves in quarto (through --execute), we set up the environment so that it contains ojs_define. But if you attempt to run it in VS Code or jupyter notebook, then those won't have access to that ojs_define call.

The only way to solve this in general is for us to have an explicit Python API for quarto. We don't have one right now (because we want to design something that looks uniform across different languages, and so the problem is bigger than just Python), but I think this is enough of a use case for us to have to think this through.

In the meantime, the workaround is for you to call quarto render ojs_jupyter.ipynb --execute.

harrylojames commented 8 months ago

Also interested in a neat solution to this 🙂 Naive to the practicalities, but could ojs_define live in the ojs block?