Hi,
I have tried to use reticulate (v 1.18) so I can do both R (4.0.3) and python (3.8) in a rmd for data analysis.
I can run python code when using the "Run" button, but when I try to knit my Rmd to a html file.
It stucked, with a message like this below.
|.......... | 14%
ordinary text without R code
|.................... | 29%
label: setup
|.............................. | 43%
ordinary text without R code
|........................................ | 57%
label: unnamed-chunk-1 (with options)
List of 1
$ engine: chr "python"
For the setup
I did this
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
use_python("/Users/xxxxx/opt/anaconda3/bin/python")
knitr::opts_chunk$set(python = reticulate::eng_python)
I also tried to replace the reticulate engine by doing this
knitr::opts_chunk$set(python.reticulate=FALSE)
And it gave me error in my second python chunk (I also import pandas in the first python chunk).
If I don't use reticulate python engine, I think to remove the error is to import python module in every single python chunk....
"NameError: name 'pd' is not defined"
Calls: <Anonymous> ... call_block -> block_exec -> in_dir -> engine -> eng_interpreted
In addition: Warning message:
Execution halted
Is there any way to fix this which I can use reticulate ?
Thx!!!