问题描述
我尝试使用命令有R 3.1.1我的电脑上安装rpy2:
I try to install rpy2 on my computer with R 3.1.1 using the command:
pip install rpy2 --user
它输出的成功,但是当我尝试使用测试它
It output success, but when I try to test it using
python -m rpy2.tests
这给我下面的错误
It give me the following error
File "/mnt/work1/software/python/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/mnt/work1/software/python/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/mnt/work1/users/home2/stamaki/.local/lib/python2.7/site-packages/rpy2-2.6.0-py2.7-linux-x86_64.egg/rpy2/tests.py", line 23, in <module>
import rpy2.tests_rpy_classic
File "/mnt/work1/users/home2/stamaki/.local/lib/python2.7/site-packages/rpy2-2.6.0-py2.7-linux-x86_64.egg/rpy2/tests_rpy_classic.py", line 3, in <module>
import rpy2.rpy_classic as rpy
File "/mnt/work1/users/home2/stamaki/.local/lib/python2.7/site-packages/rpy2-2.6.0-py2.7-linux-x86_64.egg/rpy2/rpy_classic.py", line 5, in <module>
import rpy2.rinterface as ri
File "/mnt/work1/users/home2/stamaki/.local/lib/python2.7/site-packages/rpy2-2.6.0-py2.7-linux-x86_64.egg/rpy2/rinterface/__init__.py", line 100, in <module>
from rpy2.rinterface._rinterface import *
ImportError: /mnt/work1/users/home2/stamaki/.local/lib/python2.7/site-packages/rpy2-2.6.0-py2.7-linux-x86_64.egg/rpy2/rinterface/_rinterface.so: undefined symbol: R_ClassSymbol
这SEMES象是,在C包含R的路径没有在环境变量设置casuing的 sexp.c
不包括<$编译的情况下C $ C> Rinternals.h 从R文件夹,其中 R_ClassSymbol
定义
It semes like to be the case that the C include path of R is not set in the environment variable casuing the compilation of sexp.c
does not include the Rinternals.h
from the R folders, where the R_ClassSymbol
is defined
然而,在〜/ .bashrc中
我没设置如下:
出口C_INCLUDE_PATH =到/ mnt / WORK1 /软件/ R / 3.1.1 / lib64目录/ R /包括:$ {} C_INCLUDE_PATH
出口LD_LIBRARY_PATH =到/ mnt / WORK1 /软件/ R / 3.1.1 / lib64目录/ R / lib目录下:$ {LD_LIBRARY_PATH}
However in ~/.bashrc
I did set the following: export C_INCLUDE_PATH="/mnt/work1/software/R/3.1.1/lib64/R/include:${C_INCLUDE_PATH}" export LD_LIBRARY_PATH="/mnt/work1/software/R/3.1.1/lib64/R/lib:${LD_LIBRARY_PATH}"
所以我觉得不应该发生这种错误。任何想法,为什么会发生?
So I think this error should not happen. Any Idea why it happens?
全部安装日志:
Downloading/unpacking rpy2
Running setup.py (path:/tmp/pip_build_stamaki/rpy2/setup.py) egg_info for package rpy2
R was not built as a library
R was not built as a library
/tmp/pip_build_stamaki/rpy2/setup.py:211: UserWarning: No include specified
warnings.warn('No include specified')
/tmp/pip_build_stamaki/rpy2/setup.py:222: UserWarning: No libraries as -l arguments to the compiler.
warnings.warn('No libraries as -l arguments to the compiler.')
R version 3.1.1 (2014-07-10) -- "Sock it to Me"
/mnt/work1/software/R/3.1.1/lib64/R/bin/R CMD config --ldflags
/mnt/work1/software/R/3.1.1/lib64/R/bin/R CMD config --cppflags
Compilation parameters for rpy2's C components:
include_dirs = []
library_dirs = []
libraries = []
extra_link_args = []
R version 3.1.1 (2014-07-10) -- "Sock it to Me"
warning: no files found matching 'README' anywhere in distribution
warning: no previously-included files matching '*patch*' found anywhere in distribution
warning: no previously-included files matching '*diff*' found anywhere in distribution
warning: no previously-included files matching '.hg' found anywhere in distribution
warning: no files found matching 'MANIFEST'
warning: no files found matching 'README'
warning: no files found matching 'MPL_LICENSE'
warning: no files found matching 'GPL_LICENSE'
warning: no files found matching 'LGPL_LICENSE'
no previously-included directories found matching 'dist'
warning: no files found matching 'doc/source/rpy2_logo.png'
Requirement already satisfied (use --upgrade to upgrade): six in /mnt/work1/software/python/2.7/lib/python2.7/site-packages (from rpy2)
Requirement already satisfied (use --upgrade to upgrade): singledispatch in /mnt/work1/users/home2/stamaki/.local/lib/python2.7/site-packages/singledispatch-3.4.0.3-py2.7.egg (from rpy2)
Installing collected packages: rpy2
Running setup.py install for rpy2
R was not built as a library
R was not built as a library
/tmp/pip_build_stamaki/rpy2/setup.py:211: UserWarning: No include specified
warnings.warn('No include specified')
/tmp/pip_build_stamaki/rpy2/setup.py:222: UserWarning: No libraries as -l arguments to the compiler.
warnings.warn('No libraries as -l arguments to the compiler.')
R version 3.1.1 (2014-07-10) -- "Sock it to Me"
/mnt/work1/software/R/3.1.1/lib64/R/bin/R CMD config --ldflags
/mnt/work1/software/R/3.1.1/lib64/R/bin/R CMD config --cppflags
Compilation parameters for rpy2's C components:
include_dirs = []
library_dirs = []
libraries = []
extra_link_args = []
R version 3.1.1 (2014-07-10) -- "Sock it to Me"
building 'rpy2.rinterface._rinterface' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/mnt/work1/software/python/2.7/include/python2.7 -I/mnt/work1/software/python/2.7/include/ -fPIC -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DRIF_HAS_RSIGHAND=1 -DCSTACK_DEFNS=1 -DHAS_READLINE=1 -I./rpy/rinterface -I/mnt/work1/software/python/2.7/include/python2.7 -c ./rpy/rinterface/_rinterface.c -o build/temp.linux-x86_64-2.7/./rpy/rinterface/_rinterface.o
In file included from /mnt/work1/software/python/2.7/include/python2.7/Python.h:8,
from ./rpy/rinterface/_rinterface.c:55:
/mnt/work1/software/python/2.7/include/python2.7/pyconfig.h:1161:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/signal.h:29,
from ./rpy/rinterface/_rinterface.c:51:
/usr/include/features.h:213:1: warning: this is the location of the previous definition
In file included from ./rpy/rinterface/_rinterface.c:122:
./rpy/rinterface/embeddedr.c: In function ‘SexpObject_clear’:
./rpy/rinterface/embeddedr.c:48: warning: unused variable ‘res’
In file included from ./rpy/rinterface/_rinterface.c:125:
./rpy/rinterface/sexp.c: In function ‘Sexp_init’:
./rpy/rinterface/sexp.c:738: warning: unused variable ‘copy’
./rpy/rinterface/_rinterface.c: At top level:
./rpy/rinterface/sequence.c:2174: warning: ‘ComplexVectorSexp_AsSexp’ defined but not used
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_ShowFiles’:
./rpy/rinterface/_rinterface.c:874: warning: ‘gstate’ may be used uninitialized in this function
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_ResetConsole’:
./rpy/rinterface/_rinterface.c:720: warning: ‘gstate’ may be used uninitialized in this function
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_FlushConsole’:
./rpy/rinterface/_rinterface.c:686: warning: ‘gstate’ may be used uninitialized in this function
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_ChooseFile’:
./rpy/rinterface/_rinterface.c:770: warning: ‘gstate’ may be used uninitialized in this function
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_ReadConsole’:
./rpy/rinterface/_rinterface.c:541: warning: ‘gstate’ may be used uninitialized in this function
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_WriteConsoleEx’:
./rpy/rinterface/_rinterface.c:382: warning: ‘consolecallback’ may be used uninitialized in this function
./rpy/rinterface/_rinterface.c:397: warning: ‘gstate’ may be used uninitialized in this function
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_ShowMessage’:
./rpy/rinterface/_rinterface.c:472: warning: ‘gstate’ may be used uninitialized in this function
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_CleanUp’:
./rpy/rinterface/_rinterface.c:1022: warning: ‘gstate’ may be used uninitialized in this function
gcc -pthread -shared -L/mnt/work1/software/python/2.7/lib/ -I/mnt/work1/software/python/2.7/include/python2.7 -I/mnt/work1/software/python/2.7/include/ build/temp.linux-x86_64-2.7/./rpy/rinterface/_rinterface.o -o build/lib.linux-x86_64-2.7/rpy2/rinterface/_rinterface.so
building 'rpy2.rinterface._rpy_device' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/mnt/work1/software/python/2.7/include/python2.7 -I/mnt/work1/software/python/2.7/include/ -fPIC -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DRIF_HAS_RSIGHAND=1 -DCSTACK_DEFNS=1 -DHAS_READLINE=1 -Irpy/rinterface -I/mnt/work1/software/python/2.7/include/python2.7 -c ./rpy/rinterface/_rpy_device.c -o build/temp.linux-x86_64-2.7/./rpy/rinterface/_rpy_device.o
./rpy/rinterface/_rpy_device.c:935: warning: ‘GrDev_clear’ defined but not used
gcc -pthread -shared -L/mnt/work1/software/python/2.7/lib/ -I/mnt/work1/software/python/2.7/include/python2.7 -I/mnt/work1/software/python/2.7/include/ build/temp.linux-x86_64-2.7/./rpy/rinterface/_rpy_device.o -o build/lib.linux-x86_64-2.7/rpy2/rinterface/_rpy_device.so
warning: no files found matching 'README' anywhere in distribution
warning: no previously-included files matching '*patch*' found anywhere in distribution
warning: no previously-included files matching '*diff*' found anywhere in distribution
warning: no previously-included files matching '.hg' found anywhere in distribution
warning: no files found matching 'MANIFEST'
warning: no files found matching 'README'
warning: no files found matching 'MPL_LICENSE'
warning: no files found matching 'GPL_LICENSE'
warning: no files found matching 'LGPL_LICENSE'
no previously-included directories found matching 'dist'
warning: no files found matching 'doc/source/rpy2_logo.png'
Successfully installed rpy2
Cleaning up...
另外,请不要推荐我反正需要sudo的,如因为有时重新安装R的其他reommended。我没有在系统上的管理previlages。
Besides, Please do not recommend me anyway requires sudo such as reinstall R as sometimes reommended by others. I don't have the administrative previlages on the system.
推荐答案
附近,您将看到日志的顶部,R不是建立一个库
Near the top of the logs you will see: R was not built as a library.
研究的必须的为了rpy2工作被编译为一个共享库。
R must be compiled as a shared library in order for rpy2 to work.
这篇关于无法安装rpy2正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!