Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python 3.5中使用rPython导入numpy_Numpy_Rpython - Fatal编程技术网

在python 3.5中使用rPython导入numpy

在python 3.5中使用rPython导入numpy,numpy,rpython,Numpy,Rpython,我的R版本是3.4.1,python版本是3.5.2,操作系统是Ubuntu 16.04.2 在安装RPYTHON时,我已经将RPYTHON\u PYTHON\u VERSION设置为3.5,这是我的RPYTHON的默认PYTHON版本 ♥ python.exec('import sys') ♥ python.exec('print(sys.version)') 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] 当我通过rP

我的R版本是3.4.1,python版本是3.5.2,操作系统是Ubuntu 16.04.2

在安装RPYTHON时,我已经将RPYTHON\u PYTHON\u VERSION设置为3.5,这是我的RPYTHON的默认PYTHON版本

♥ python.exec('import sys')
♥ python.exec('print(sys.version)')
3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609]
当我通过rPython导入numpy时(在python 3.5中使用import numpy没有问题,一切正常),我得到了以下结果:

♥ python.exec('import numpy')
Error in python.exec("import numpy") :
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: /usr/local/lib/python3.5/dist-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so: undefined symbol: PyType_GenericNew

但是,如果我将RPYTHON\u PYTHON\u VERSION设置为2并重新安装RPYTHON,那么import numpy可以工作。如何使用python 3.5在rPython下成功导入numpy?

首先,您能从R/rPython将任何包导入python 3.5.3吗

我也有这个问题。我得到的错误与海报完全相同(numpy不会加载)。我后来发现我无法导入任何包。但是,我可以导入Python2.7.13和Python3.5.3中的包(只是不能通过R/rPython)。这让我相信这是一个“rPython”R包错误。以下是我为解决此问题所做的尝试:

1) 我已经尝试过安装/重新安装R包rPython以使用python 2.7.13或python 3.5.3。我可以通过重新安装rPython包将R连接到python 2.7.13:

install.packages("rPython",lib= "home/myusername/R/x86_64-pc-linux-gnu-library/3.4", configure.vars= "RPYTHON_PYTHON_VERSION=2")
在安装过程中使用“RPYTHON\u PYTHON\u VERSION=3”同样允许我将R与PYTHON 3.5.3连接起来。当rPython连接到Python2.7.13时,我可以从R调用“import numpy”,但当连接到3.5.3时,就不能了

2) 我已经找到了以前安装和卸载过的所有numpy和scipy。我为Python2.7.13和Python3.5.3各准备了几份副本。使用pip和pip3重新安装并没有解决问题(为了安全起见,我提前重新启动了R)

从这两个帐户来看,这似乎是R包“rPython”的一个问题。您可以尝试R中较新的“网状”软件包,看看这是否更适合您。然而,在使用网状结构将R与python连接时,我无法让并行线程工作,不幸的是,这正是我需要做的。然而,当使用“rPython”时,线程确实可以完美地工作,但是我需要的包需要python 3+。如果我能解决这个问题,我会继续排除故障并更新这个帖子。同时,给“网状”一个机会,它是一个非常整洁的包装

编辑 我能够使用“网状”包在R中从python 3.5.3加载numpy


EDIT2对于那些将来找到这篇文章的人,我能找到的使用python3代码和R中的多线程的唯一解决方案是使用系统调用python文件(python3“path\u to\u python\u script”arg1 arg2 arg3)

谢谢Bartimus,我已经尝试了Networkite(由Rstudio guys开发,网纹蟒蛇是世界上最长的蛇lol)它可以用python 3.5导入numpy。回答你的问题,是的,我可以导入其他一些包,例如pymongo、datetime和bson,除了rPython下的numpy和python 3.5。我唯一关心的是在R中集成python3,所以你真的帮了我的忙,再次感谢。