我在让R中的reticulate
包正常工作时遇到了麻烦。
无论我通过LIBPYTHON
加载了哪个Python版本,或者我告诉module load
使用哪个版本,它都无法直接在R中找到所需的共享reticulate
文件。
我正在大学集群上工作,该集群安装了多个版本的Python,并通过模块加载。
谢谢您的帮助。
a)使用版本2.7.9(module load CBC
的默认版本):
> reticulate::py_discover_config()
python: /opt/Python/Python-2.7.9/bin/python
libpython: /opt/Python/Python-2.7.9/lib/libpython2.7.so[NOT FOUND]
pythonhome: /opt/Python/Python-2.7.9:/opt/Python/Python-2.7.9
version: 2.7.9 (default, Apr 23 2015, 22:07:47) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
numpy: /opt/Python/Python-2.7.9/lib/python2.7/site-packages/numpy
numpy_version: 1.9.2
b)通过在reticulate
的R中指定使用2.7.10版本:
> reticulate::use_python("/opt/Python/Python-2.7.10/bin/python2")
> reticulate::py_discover_config()
/opt/Python/Python-2.7.10/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
Error in system2(command = python, args = paste0("\"", config_script, :
error in running command
c)通过在开始R /加载module load CBC python/2.7.10
之前运行reticulate
来使用2.7.10版本:
> system("which python")
/opt/Python/Python-2.7.10/bin/python
> library(reticulate)
> py_discover_config()
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "/home/csandoval/R/x86_64-pc-linux-gnu-library/3.5/reticulate/config/config.py", line 3, in <module>
import os
File "/opt/Python/Python-2.7.10/lib/python2.7/os.py", line 400, in <module>
import UserDict
File "/opt/Python/Python-2.7.10/lib/python2.7/UserDict.py", line 84, in <module>
_abcoll.MutableMapping.register(IterableUserDict)
File "/opt/Python/Python-2.7.10/lib/python2.7/abc.py", line 109, in register
if issubclass(subclass, cls):
File "/opt/Python/Python-2.7.10/lib/python2.7/abc.py", line 184, in __subclasscheck__
cls._abc_negative_cache.add(subclass)
File "/opt/Python/Python-2.7.10/lib/python2.7/_weakrefset.py", line 86, in add
self.data.add(ref(item, self._remove))
TypeError: cannot create weak reference to 'classobj' object
Error in python_config(python_version, required_module, python_versions) :
Error 1 occurred running /usr/bin/python
In addition: Warning message:
In system2(command = python, args = paste0("\"", config_script, :
running command ''/usr/bin/python' "/home/csandoval/R/x86_64-pc-linux-gnu-library/3.5/reticulate/config/config.py"' had status 1
共享库(.so
)文件似乎确实存在,至少存在于2.7.10,所以我完全不知道下一步该怎么做:
> locate 'libpython2'
/opt/Python/Python-2.7.10/lib/libpython2.7.so
/opt/Python/Python-2.7.10/lib/libpython2.7.so.1.0
/opt/Python/Python-2.7.10/lib/python2.7/config/libpython2.7.a
/opt/Python/Python-2.7.3/lib/libpython2.7.a
/opt/Python/Python-2.7.3/lib/python2.7/config/libpython2.7.a
/opt/Python/Python-2.7.4/lib/libpython2.7.a
/opt/Python/Python-2.7.4/lib/python2.7/config/libpython2.7.a
/opt/Python/Python-2.7.9/lib/libpython2.7.a
/opt/Python/Python-2.7.9/lib/python2.7/config/libpython2.7.a
/opt/local/lib/libpython2.6.a
/opt/local/lib/libpython2.6.a.old
/opt/local/lib/python2.6/config/libpython2.6.a
/opt/local/lib/python2.6.old/config/libpython2.6.a
/opt/scyld/python/2.6.5/lib/libpython2.6.so
/opt/scyld/python/2.6.5/lib/libpython2.6.so.0.1
/opt/scyld/python/2.6.5/lib/python2.6/config/libpython2.6.a
/usr/cellprofiler/lib/libpython2.7.so
/usr/cellprofiler/lib/libpython2.7.so.1.0
/usr/cellprofiler/lib/python2.7/config/libpython2.7.a
/usr/lib64/libpython2.6.so
/usr/lib64/libpython2.6.so.1.0
/usr/lib64/python2.6/config/libpython2.6.so
/usr/share/systemtap/tapset/libpython2.6-64.stp