You don't specify what platform you are on (linux / Windows / other), and what tools you are using. I am running a linux system and I have virtual environments set up. I set the environment variable RETICULATE_PYTHON to point to python (in my virtual environment). I am using RStudio, and I use the File pulldown menu and select New File --> 'R Markdown' or New File --> 'Quarto document'. In the R Markdown (or Quarto) document, create a python code chunk:
```{python} import numpy as np print(np.arange(5)) ``` works for me. HTH, Eric On Fri, Jan 20, 2023 at 6:20 PM Kai Yang via R-help <r-help@r-project.org> 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 > > > > > > > > > > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.