[R] Problem to run python code in r markdown

Milan Glacier new@ @end|ng |rom m||@ng|@c|er@com
Fri Jan 20 21:30:03 CET 2023


Maybe it is the order. You called py_install() first and then called
use_condaenv(). Perhaps you need to switch to your conda env first and
then call py_install().

On 01/20/23 16:20, Kai Yang via R-help wrote:
>Hi Team,I'm trying to run python in R markdown (flexdashboard). The code is below:
>
>try Python=============
>```{r, include=FALSE, echo=TRUE}library(reticulate)py_install("numpy")
>use_condaenv("base")
>```
>```{python}import numpy as np```
>
>I got error message below:
>Error in py_call_impl(callable, dots$args, dots$keywords) :   ModuleNotFoundError: No module named 'numpy'Calls: <Anonymous> ... py_capture_output -> force -> <Anonymous> -> py_call_implIn addition: There were 26 warnings (use warnings() to see them)Execution halted
>
>
>Based on message, the python can not find numpy package. But I'm sure I installed the package. I don't know how to fix the problem. please help
>Thank you,Kai



More information about the R-help mailing list