Setting python environment with engine.path leads to error

rmarkdown
python

#1

I am trying to use my anaconda installation of python 3.6.5 in rmarkdown. I read that I can use the engine.path chunk option to point to the installation and use that to run my python cells.

I've included a minimal working example below. When I knit the document with the knit button in R studio, I get the following error:

processing file: Untitled.Rmd
  |.............                                                    |  20%
  ordinary text without R code

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

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

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

Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.dylib.

Here is my example:

---
title: ""
author: ""
date: ''
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, 
                    engine.path = list(python = '~/anaconda3/bin/python'))
```

## Section 

Here I am using python in R studio

```{python}
import sklearn
```

This error persists when i explicitly set the engine path in the python chunk.

The code chunk runs when I explicitly pass the engine, but not when I use knitr::opts_chunk$set( engine.path = list(python = '~/anaconda3/bin/python')).

Is this expected behavior? What does the error mean?

Here is my session info:

> devtools::session_info('rmarkdown')
Session info ----------------------------------------------------
 setting  value                       
 version  R version 3.4.3 (2017-11-30)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.1.453)           
 language (EN)                        
 collate  en_CA.UTF-8                 
 tz       America/Toronto             
 date     2018-08-09                  

Packages --------------------------------------------------------
 package   * version date       source        
 backports   1.1.2   2017-12-13 CRAN (R 3.4.3)
 base64enc   0.1-3   2015-07-28 CRAN (R 3.4.0)
 digest      0.6.15  2018-01-28 CRAN (R 3.4.3)
 evaluate    0.11    2018-07-17 CRAN (R 3.4.4)
 glue        1.3.0   2018-07-17 CRAN (R 3.4.4)
 graphics  * 3.4.3   2017-12-07 local         
 grDevices * 3.4.3   2017-12-07 local         
 highr       0.7     2018-06-09 CRAN (R 3.4.4)
 htmltools   0.3.6   2017-04-28 CRAN (R 3.4.0)
 jsonlite    1.5     2017-06-01 cran (@1.5)   
 knitr       1.20    2018-02-20 CRAN (R 3.4.3)
 magrittr    1.5     2014-11-22 CRAN (R 3.4.0)
 markdown    0.8     2017-04-20 CRAN (R 3.4.0)
 methods   * 3.4.3   2017-12-07 local         
 mime        0.5     2016-07-07 CRAN (R 3.4.0)
 Rcpp        0.12.18 2018-07-23 CRAN (R 3.4.4)
 rmarkdown   1.10    2018-06-11 CRAN (R 3.4.4)
 rprojroot   1.3-2   2018-01-03 CRAN (R 3.4.3)
 stats     * 3.4.3   2017-12-07 local         
 stringi     1.2.4   2018-07-20 CRAN (R 3.4.4)
 stringr     1.3.1   2018-05-10 CRAN (R 3.4.4)
 tinytex     0.6     2018-07-07 CRAN (R 3.4.4)
 tools       3.4.3   2017-12-07 local         
 utils     * 3.4.3   2017-12-07 local         
 xfun        0.3     2018-07-06 CRAN (R 3.4.4)
 yaml        2.2.0   2018-07-25 CRAN (R 3.4.4)