Knitting in R-Markdown file stops without printing error when hitting a python chunk

时光总嘲笑我的痴心妄想 提交于 2021-01-24 18:59:27

问题


I'm used to R, but new to R markdown. I would like to insert python chunks in the code. However, I cannot get it to work. Every time I press "Knit", it starts knitting until it hits the first python chuck. Then it just pauses, without providing an error message.

I've tried using many example codes setting up a python engine with reticulate and knitr from the internet, but none of them work. I've specified different python files, versions, etc. It seems like I'm missing something, but I cannot figure out what it is.

The code I've used:

---
title: "Test3"
author: "Stanny"
date: "11 september 2019"
output: pdf_document
#
---

## Set-up

```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
use_python("C:\\Users\\STANNY~1\\OneDrive\\envs\\wiki\\python.exe")
```

## A normal R code chunk

```{r}
library(reticulate)
x = 42
print(x)
```

## A Python chunk

```{python}
x = 42 * 2
print(x) 
```

## Modify a Python variable

```{python}
x = x + 18 
print(x)
```

The output:

processing file: test3.Rmd
  |........                                                         |  12%
  ordinary text without R code

  |................                                                 |  25%
label: setup (with options) 
List of 1
 $ include: logi FALSE

  |........................                                         |  38%
  ordinary text without R code

  |................................                                 |  50%
label: unnamed-chunk-1
  |.........................................                        |  62%
  ordinary text without R code

  |.................................................                |  75%
label: unnamed-chunk-2 (with options) 
List of 1
 $ engine: chr "python"

回答1:


saddly is not possible to run python on flexdashboard :(
https://github.com/yihui/knitr/issues/1667



来源:https://stackoverflow.com/questions/57895993/knitting-in-r-markdown-file-stops-without-printing-error-when-hitting-a-python-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!