微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在rmarkdown中使用python时出错py_call_implcallable,dots $ args,dots $ keywords中的错误...

如何解决在rmarkdown中使用python时出错py_call_implcallable,dots $ args,dots $ keywords中的错误...

我有以下rmarkdown代码

---
title: "test"
output: html_document
---

```{r setup,include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
use_condaenv(condaenv = "daniellgaenv",conda = r"(C:\Users\danie\anaconda3\envs\daniellgaenv)",required = TRUE)
```

```{python}
a = [1,2,3]
```

在运行python块时,它给了我错误

Error in py_call_impl(callable,dots$args,dots$keywords) : 
  TypeError: use() got an unexpected keyword argument 'warn'

我的系统信息:

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  Grdevices utils     datasets  methods   base     

other attached packages:
[1] reticulate_1.16

loaded via a namespace (and not attached):
[1] compiler_4.0.2  Matrix_1.2-18   tools_4.0.2     Rcpp_1.0.5      grid_4.0.2      knitr_1.29      jsonlite_1.7.0 
[8] xfun_0.16       lattice_0.20-41

和来自网状结构:

> reticulate::py_numpy_available()
[1] TRUE
> reticulate::py_config()
python:         C:/Users/danie/anaconda3/envs/daniellgaenv/python.exe
libpython:      C:/Users/danie/anaconda3/envs/daniellgaenv/python37.dll
pythonhome:     C:/Users/danie/anaconda3/envs/daniellgaenv
version:        3.7.9 (default,Aug 31 2020,17:10:11) [MSC v.1916 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:/Users/danie/anaconda3/envs/daniellgaenv/Lib/site-packages/numpy
numpy_version:  1.19.1

NOTE: Python version was forced by use_python function

使用repl_python在终端上工作时,相同的代码也起作用:

> reticulate::repl_python()
Python 3.7.9 (C:/Users/danie/anaconda3/envs/daniellgaenv/python.exe)
Reticulate 1.16 REPL -- A Python interpreter in R.
>>> a = [1,3]
>>> a
[1,3]

有人知道如何解决此问题吗?

解决方法

请参阅https://github.com/rstudio/reticulate/issues/831

该问题应通过网状结构的开发版本解决

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。