Skip to content
Advertisement

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. 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()

> 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

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.

Advertisement

Answer

It seems that your GCC is too old to be used with your R module. This issue is not related to R but the error message is the same.

Do you have several installations of GCC (in particular in /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.

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). Then, you will need to run R with your new environment.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement