简体   繁体   中英

Render quarto document with both R and python code

I'm using quarto html format to produce a document with both python and R code. The rendering was smooth until I added the first python lines of python code:

import requests
url = 'some/url'
page = requests.get(url)

The code works just fine without rendering, so I can't spot my mistake.

This is the error message from the RStudio "Background Jobs" pane:

Jupyter is not available in this Python installation.
Install with py -m pip install jupyter

Should I install jupyter, even if I'm using the knitr engine for rendering?

EDIT (YAML section)

---
title: "Web scrapping"
author: "Diabb Zegpi"
format: 
  html:
    self-contained: true
    theme: [default, custom.scss]
editor: visual
lang: es
editor_options: 
  chunk_output_type: inline
---

You can render a document with both R and python code with the knitr engine specified, if you have the {reticulate} r-package installed in your computer. Also note that, for knitr to identify the python code you need to use python as the chunk header.

---
title: "R and Python"
format: html
engine: knitr
---

## R

```{r}
x = sample(1:100, size = 1000, replace = TRUE)
y = rnorm(1000, mean = 40, sd = 2)

plot(x, y)
```


## python

```{python}
import requests

x = requests.get('https://www.wikipedia.org/')

print(x.text)
```

quarto 使用 R 和 python 代码渲染 html 输出


The rendering worked after running tthe suggested line in the terminal:

py -m pip install jupyter

I still don't know why and what jupyter has to do with knitr rendering.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM