我正在尝试使用R中的熊猫。我使用了网状库。我使用的示例代码如下
library(reticulate)
use_condaenv("my_env_37",required=T)
py_discover_config()
py_run_string("import pandas as pd")
错误
> py_run_string("import pandas as pd")
Error in py_run_string_impl(code, local, convert) :
ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /opt/anaconda/envs/my_env_37/lib/python3.6/site-packages/pandas/_libs/window.cpython-36m-x86_64-linux-gnu.so)
Detailed traceback:
File "<string>", line 1, in <module>
File "/opt/anaconda/envs/my_env_37/lib/python3.6/site-packages/pandas/__init__.py", line 42, in <module>
from pandas.core.api import *
File "/opt/anaconda/envs/my_env_37/lib/python3.6/site-packages/pandas/core/api.py", line 26, in <module>
from pandas.core.groupby import Grouper
File "/opt/anaconda/envs/my_env_37/lib/python3.6/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
from pandas.core.groupby.groupby import GroupBy # noqa: F401
File "/opt/anaconda/envs/my_env_37/lib/python3.6/site-packages/pandas/core/groupby/groupby.py", line 37, in <module>
from pandas.core.frame import DataFrame
File "/opt/anaconda/envs/my_env_37/lib/python3.6/si
Calls: py_run_string -> py_run_string_impl
Execution halted
py_discover_config()
的输出
> py_discover_config()
python: /opt/anaconda/envs/my_env_37/bin/python
libpython: /opt/anaconda/envs/my_env_37/lib/libpython3.6m.so
pythonhome: /opt/anaconda/envs/my_env_37:/opt/anaconda/envs/my_env_37
version: 3.6.8 |Anaconda custom (64-bit)| (default, Dec 30 2018, 01:22:34) [GCC 7.3.0]
numpy: /opt/anaconda/envs/my_env_37/lib/python3.6/site-packages/numpy
numpy_version: 1.16.2
NOTE: Python version was forced by use_python function
Conda版本:4.6.8
Python版本:3.6.8
熊猫版本:0.24.2
操作系统:RHEL 7.4
R版本:3.5.1
网状版本:1.9
要使此功能正常工作,还有其他配置需要使用吗?当我单独从Python运行相同的熊猫导入时,它按预期运行。
答案 0 :(得分:1)
您的GCC似乎太旧了,无法与R模块一起使用。 This issue与R无关,但错误消息相同。
您是否已安装了多个GCC(特别是在/ usr / local中)?如果是这样,您可以尝试我之前给出的链接中建议的类似export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64
的方法。
否则,您应该安装较新版本的GCC(如果仍需要当前版本的GCC,则在模块环境中,有关详细信息,请参见here,IMHO的解释非常清楚)。然后,您将需要在新环境中运行R。