python - How to choose the environment in a python chunk in rmarkdown
问题描述
I try to get familiar with python in R. I made it work using reticulate along the following lines:
library(reticulate)
py_install("pandas")
Then I can always get back to the enviroment where I installed that to using
use_condaenv("r-reticulate")
How can I use this in a python chunk of the following form
```{python}
import pandas as pd
```
pandas can be found in the first version above (using reticulate) but not in the version with the python chunk. How can I tell it to use the "r-reticulate" environment? Setting it in an R set-up chunk in the following form does not work for me
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
use_condaenv("r-reticulate")
```
解决方案
I had the same issue, it was fixed by setting the required
keyword to TRUE
.
use_condaenv(condaenv='env-name', required = TRUE)
推荐阅读
- php - 两个 php7-apache docker 映像,一个有效,另一个无效。找不到区别
- r - 如何在ggplot2中产生没有卷曲的λ?
- mysql - 这个加入可能吗?
- android - 如何使用独立的 Jetifier 迁移到 AndroidX?
- python - SQL外键 - 单个ID中的多个产品?
- java - 是否有任何类似 JNI 的机制允许 C 代码直接绘制 Java 控件?
- reactjs - 重用具有不同方法调用的反应组件
- jquery - jQuery触发按钮单击页面滚动
- istio - 无法通过 Kubernetes REST API 创建/获取 Istio 对象
- angular - ngFor 匹配键值