没有名为"rpytools"的模块? [英] No module named 'rpytools'?

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

问题描述

我正在尝试使用R中的网状库.我使用"functions.py"示例对其进行了测试:

I'm trying to work with the reticulate library in R. I used the "functions.py" example to test it out:

# functions.py file
def add(x, y): 
    return x + y

在R Studio(版本3.5.2)中,这就是我所拥有的:

In R studio (Version 3.5.2), this is what I have:

library(reticulate)  
source_python('functions.py')

但是,这将返回错误:

Error in py_set_attr_impl(x, name, value) : 
  Evaluation error: ModuleNotFoundError: No module named 'rpytools'.

所以我被困在这里.如果有帮助,我还将分享我的Python是64位版本3.6.5.有人知道该怎么做吗?

So I'm stuck here. If it helps, I'll also share that my Python is 64-bit and version 3.6.5. Anyone know how to go about this?

谢谢

推荐答案

rpytools reticulate 提供的模块,应放在您的模块路径上.例如,我看到:

rpytools is a module provided by reticulate and should be placed on the module path for you. For example, I see:

> library(reticulate)
> sys <- import("sys", convert = TRUE)
> sys$path
 [1] ""                                                                                                          
 [2] "/usr/local/Cellar/python@2/2.7.15_3/Frameworks/Python.framework/Versions/2.7/bin"                          
 [3] "/Users/kevin/Library/Python/2.7/lib/python/site-packages/pip-18.1-py2.7.egg"                               
 [4] "/Users/kevin/Library/Python/2.7/lib/python/site-packages/virtualenv-16.0.0-py2.7.egg"                      
 [5] "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python27.zip"                         
 [6] "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python2.7"                            
 [7] "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin"                
 [8] "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac"                   
 [9] "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages"
[10] "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk"                     
[11] "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old"                    
[12] "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload"                
[13] "/Users/kevin/Library/Python/2.7/lib/python/site-packages"                                                  
[14] "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"              
[15] "/Users/kevin/Library/R/3.5/library/reticulate/python"     

请注意最后一个条目,该条目提供导入时在其中找到 rpytools 的路径.你看到类似的东西吗?

Note the last entry, which provides the path where rpytools would be found on import. Do you see something similar?

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

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