简体   繁体   English

R 网状 package 未找到 Python win32com 模块

[英]R reticulate package not finding Python win32com module

I'm trying to use reticulate in R to access Python's win32com (in order to read password-protected Excel documents), but am failing at the first hurdle.我正在尝试在 R 中使用reticulate来访问 Python 的win32com (以读取受密码保护的 Excel 文档),但在第一个障碍中失败了。 Although my code works fine in Python, when trying to use it in reticulate , the win32com module cannot be found.尽管我的代码在 Python 中运行良好,但尝试在reticulate中使用它时, win32com模块。

As an example:举个例子:

library(reticulate)
virtualenv_create("r-reticulate-test")
py_install(envname = "r-reticulate-test", packages = "pywin32")
win32 = import("win32com.client")

Results in:结果是:

Error in py_module_import(module, convert = convert) : 
    ModuleNotFoundError: No module named 'win32com'

I had the same problem and the following solved the issue:我有同样的问题,以下解决了这个问题:

library(reticulate)
install.packages("Rcpp")
virtualenv_create("r-reticulate-test")
py_install("pypiwin32", pip = T, envname = "r-reticulate-test")
win32 <- import("win32com.client")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM