Python in R markdown

Viewed 257

I ve tried to run a simple python code in R markdown, but got the unclear error. Here is the code:

 ```{r setup, include=FALSE}
pacman::p_load(plyr, psych, lmtest, ggplot2, reticulate)
use_condaenv("Mlearn") #Anaconda env
```

```{python}
for i in range(10):
  print('Number')
  print(i)
```

Then, the error:Show in New Window

INTEL MKL ERROR: dlopen(/Users/user1/opt/anaconda3/envs/mlearn/lib/libmkl_intel_thread.1.dylib, 9): Library not loaded: @rpath/libiomp5.dylib
  Referenced from: /Users/user1/opt/anaconda3/envs/mlearn/lib/libmkl_intel_thread.1.dylib
  Reason: image not found.
Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.1.dylib.

Could please anyone explain: How to run python code in R markdown when it is installed Anaconda navigator? Certainly, what the commands should I enter? I searched almost everywhere, but I didn t find something useful. And i changed in "preferences" path to the Anaconda, but it is still does not work.

UPD1: I ve installed library mkl via terminal, then, R session stopped to break each time, then the problem solved.

UPD2: I see that matplotlib plots works badly via markdown. That’s not good.

1 Answers

I update mkl with

conda install mkl

and that works for me, in case someone have the same error.

Related