ModuleNotFoundError:使用网状库时,没有名为"rpytools"的模块 [英] ModuleNotFoundError: No module named 'rpytools' while using reticulate library

查看:329
本文介绍了ModuleNotFoundError:使用网状库时,没有名为"rpytools"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,这是我的第一个stackoverflow问题,对于任何错误,请提前抱歉.我正在尝试开始使用R reticulate库.我已经安装了该软件包,并尝试导入os Python模块.一切似乎都还可以,但是随后当我开始输入例如os$listdir R时,会引发此错误:Error in py_module_import(module, convert = convert) : ModuleNotFoundError: No module named 'rpytools'.这是我的整个代码:

Hi this is my first stackoverflow question so sorry in advance for any mistakes. I am trying to start playing with R reticulate library. I have installed the package, and tried to import os Python module. Everything seemed to be ok, but then while I start typing for example os$listdir R throws this error: Error in py_module_import(module, convert = convert) : ModuleNotFoundError: No module named 'rpytools'. Here is my entire code:

install.packages("reticulate")
library(reticulate)
os <- import("os")
os$listdir("")

这是我的py_config()的输出:

python:         C:\PROGRA~3\ANACON~1\python.exe
libpython:      C:/PROGRA~3/ANACON~1/python36.dll
pythonhome:     C:\PROGRA~3\ANACON~1
version:        3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:\PROGRA~3\ANACON~1\lib\site-packages\numpy
numpy_version:  1.12.1
os:             C:\PROGRA~3\ANACON~1\lib\os.py

py_available(TRUE)返回TRUE ...

如果需要任何其他信息,请给我写信.

Please write me if there is any additional info needed.

推荐答案

简短的回答是您需要使用RStudio 1.2或更高版本,当前仅可作为

The short answer is you need to use RStudio version 1.2 or higher, currently only available as a preview release, to get experimental reticulate support.

当前RStudio稳定版本(< 1.2)中对reticulate的支持非常不稳定,一旦尝试使用导入的模块,使用RStudio< 1.2作为Python IDE的任何希望就会瓦解.在reticulate文档:中,这被称为即时注释. >

Support for reticulate in current RStudio stable releases (<1.2) is pretty flaky and any hope of using RStudio <1.2 as a Python IDE falls apart as soon as you try to work with imported modules. This is mentioned as an offhand comment in the reticulate docs:

请注意,RStudio v1.2预览版本包括对使用网状图在R Notebooks中执行Python块的支持.有关其他详细信息,请参见 RStudio IDE网状工具文章.

您的代码在RStudio 1.2中不会引发错误:

Your code doesn't throw an error in RStudio 1.2:

> library(reticulate)
> os <- import("os")
> os$listdir()
 [1] ".Rhistory"         ".Rproj.user"     

这篇关于ModuleNotFoundError:使用网状库时,没有名为"rpytools"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆