简体   繁体   English

R 网状 libstdc++so GLIBCXX_3.4.21 未找到问题

[英]R reticulate libstdc++so GLIBCXX_3.4.21 not found issue

I was trying to use pandas from R. I used the reticulate library for the same.我试图使用 R 中的 pandas。我也使用了网状库。 The sample code I used is given below我使用的示例代码如下

library(reticulate) use_condaenv("my_env_37",required=T) py_discover_config() py_run_string("import pandas as pd")

Error错误

> 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

Output from py_discover_config() Output 来自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 version: 4.6.8 Python Version: 3.6.8 Pandas Version: 0.24.2 OS: RHEL 7.4 R Version: 3.5.1 reticulate Version: 1.9 Conda 版本: 4.6.8 Python 版本: 3.6.8 Pandas 版本: 0.24.2操作系统: RHEL 7.4 R 版本: 3.5.1网状版本: 1.9

Is there any other configuration we have to use for getting this working.我们是否必须使用任何其他配置才能使其正常工作。 When I run the same pandas import from Python alone it is working as expected.当我单独运行相同的 pandas import from Python 时,它按预期工作。

It seems that your GCC is too old to be used with your R module. 您的GCC似乎太旧了,无法与R模块一起使用。 This issue is not related to R but the error message is the same. 此问题与R无关,但错误消息相同。

Do you have several installations of GCC (in particular in /usr/local)? 您是否安装了多个GCC(尤其是在/ usr / local中)? If so, you can try something like export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64 as suggested in the previous link I gave. 如果是这样,您可以按照我之前给出的链接中的建议尝试执行类似export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64

Otherwise, you should install a newer version of GCC (in a module environment if you still need your current version of GCC, see here for details, the explanations are very clear IMHO). 否则,您应该安装较新版本的GCC(如果仍需要当前版本的GCC,则在模块环境中,请参见此处以了解详细信息,IMHO的解释非常清楚)。 Then, you will need to run R with your new environment. 然后,您将需要在新环境中运行R。

I ran into a similar issue in a GitHub Action, and this answer finally help me after many trials .我在 GitHub Action 中遇到了类似的问题,经过多次尝试这个答案终于帮助了我。 Essentially, I added the following as a step in my.github/workflows/pythonapp.yml file:本质上,我在 my.github/workflows/pythonapp.yml 文件中添加了以下步骤:

conda install -c conda-forge libstdcxx-ng
sudo rm /usr/lib/x86_64-linux-gnu/libstdc++.so.6
sudo ln -s /home/runner/.local/share/r-miniconda/pkgs/libstdcxx-ng-12.1.0-ha89aaad_16/lib/libstdc++.so.6.0.30 /usr/lib/x86_64-linux-gnu/libstdc++.so.6

Explanation解释

My initial error was:我最初的错误是:

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/runner/.local/share/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/scipy/optimize/_highs/_highs_wrapper.cpython-38-x86_64-linux-gnu.so)

so I needed to remove the existing libstdc++.so.6 and make a symlink for it in /usr/lib/x86_64-linux-gnu/.所以我需要删除现有的 libstdc++.so.6 并在 /usr/lib/x86_64-linux-gnu/ 中为其创建符号链接。

find / -name "libstdc++.so*" showed me where my libstdc++.so.6.0.30 file was, so then the last step was to point the symlink there. find / -name "libstdc++.so*"告诉我我的 libstdc++.so.6.0.30 文件在哪里,所以最后一步是将符号链接指向那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM