Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`GLIBCXX_3.4.21' not found #841

Open
slfan2013 opened this issue Sep 5, 2020 · 10 comments
Open

`GLIBCXX_3.4.21' not found #841

slfan2013 opened this issue Sep 5, 2020 · 10 comments

Comments

@slfan2013
Copy link

slfan2013 commented Sep 5, 2020

The following code give me error:

reticulate::import('tensorflow')
Error in py_module_import(module, convert = convert) :
  ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/slfan/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/google/protobuf/pyext/_message.cpython-36m-x86_64-linux-gnu.so)

Please see my config.

py_config()
python:         /home/slfan/.local/share/r-miniconda/envs/r-reticulate/bin/python
libpython:      /home/slfan/.local/share/r-miniconda/envs/r-reticulate/lib/libpython3.6m.so
pythonhome:     /home/slfan/.local/share/r-miniconda/envs/r-reticulate:/home/slfan/.local/share/r-miniconda/envs/r-reticulate
version:        3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 23:51:54)  [GCC 7.3.0]
numpy:          /home/slfan/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/numpy
numpy_version:  1.19.1

I am using a Linux server system.

@kevinushey kevinushey reopened this Sep 8, 2020
@kevinushey
Copy link
Collaborator

The problem here is that your Anaconda environment + your system's own library are requesting incompatible versions of the C++ standard library. You likely need to set LD_LIBRARY_PATH to ensure libraries from the Anaconda installation are used instead.

@slfan2013
Copy link
Author

Shoud I set LD_LIBRARY_PATH in R or in the system, using sudo...?

@alexvorobiev
Copy link

Since reticulate wants R to load libpython.so which in turn needs newer libc than the one R was originally compiled with, LD_LIBRARY_PATH should be set prior to calling R. Unfortunately, due to the peculiar nature of libc, setting LD_LIBRARY_PATH is not going to be enough. The reason is libc should match the so called dynamic linker R is using to load the shared libraries. Basically you need to adjust the location of the dynamic linker stored in the R executable. Here are the step by step instructions https://stackoverflow.com/a/44710599/973603.

I have not tried them with Anaconda but I was facing the same issue with python (but not R) installed by Nix package manager and that approach worked. One issue you may encounter is the R executable doesn't do much - all the actual functionality is in libR.so which may have its own missing dependencies. Fortunately those can be resolved by setting LD_LIBRARY_PATH prior to calling R.

@trangdata
Copy link

I ran into a similar issue in a GitHub Action, and this answer finally help me after many trials (including setting LD_LIBRARY_PATH). Essentially, I added the following as a step in my .github/workflows/pythonapp.yml file:

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/.

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.

@carmensandoval
Copy link

carmensandoval commented Oct 3, 2022

Is it possible to tell reticulate to look for the library in question in the conda environment lib directory?

@yoshidk6
Copy link

yoshidk6 commented Oct 9, 2022

I took a shortcut and used an older version of a Python package (in my case xgboost) and that worked fine (detail: #1282 (comment)). Posting it here just in case this info can be helpful for some, especially for those without sudo access

@hhaensel
Copy link

hhaensel commented Nov 3, 2022

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

for my Dockerfile I even shortened that by using the force option

ln -sf /opt/conda/lib/libstdc++.so /opt/julia-1.8.2/lib/julia/libstdc++.so
ln -sf /opt/conda/lib/libstdc++.so.6 /opt/julia-1.8.2/lib/julia/libstdc++.so.6

Your post saved me <3 ❤️

@trangdata
Copy link

I ran into a similar issue in a GitHub Action, and this answer finally help me after many trials (including setting LD_LIBRARY_PATH). Essentially, I added the following as a step in my .github/workflows/pythonapp.yml file:

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

Update on 2023-02-19: It looks like this issue has been fixed somewhere upstream (and perhaps thanks to the updated r-lib actions to v2?). Anyhow, I had to now remove this step (called Install gcc step in my action file).

@legel
Copy link

legel commented Mar 21, 2023

conda install -c conda-forge libstdcxx-ng
solved my problem!

@Clear-3d
Copy link

conda install -c conda-forge libstdcxx-ng solved my problem!

Thanks a lot!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants