Anaconda libstdc++.so.6: version `GLIBCXX_3.4.20' not found
Asked Answered
S

11

24

I am using anaconda for python and I face this problem I tried a lot to solve this error, but still not solved.

I used the following commands so far

sudo apt-get install libstdc++6
sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

conda install libgcc

in this link a solution provided but I still don't know how to do that

Shanon answered 25/1, 2018 at 23:20 Comment(2)
Images with text : Please replace with text ! Quite an old OS you have there : GLIBCXX_3.4.20 is an object from the gcc-4.9.x libstdc++.so.6.0.20 . Please edit your question to include OS name, version, architecture.Kerley
I could solve this problem by removing and installing Anaconda after a lot of effort that I could not solve it. thanks for your commentShanon
F
23

This is because you have some old versions not cleaned up while upgrading gcc.

First of all, make sure that you have the latest lib with conda install -c conda-forge libstdcxx-ng

  1. Find all your lib versions with find / -name "libstdc++.so*". My latest version is 6.0.30.
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.29
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.so
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.so.6.0.29
/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.so.6.0
/opt/conda/lib/libstdc++.so.6.0.29
/opt/conda/lib/libstdc++.so.6
/opt/conda/envs/xxx/lib/libstdc++.so.6.0.30
/opt/conda/envs/xxx/lib/libstdc++.so.6
/opt/conda/pkgs/libgcc-7.2.0-h69d50b8_2/lib/libstdc++.so.6.0.21
/opt/conda/pkgs/libstdcxx-ng-12.1.0-ha89aaad_16/lib/libstdc++.so.6.0.30
/opt/conda/pkgs/libstdcxx-ng-12.1.0-ha89aaad_16/lib/libstdc++.so.6
/opt/conda/pkgs/libstdcxx-ng-12.1.0-ha89aaad_16/lib/libstdc++.so
  1. Copy the file to the folder where you are working at and only have the old versions. /opt/conda/lib/ or /opt/conda/envs/xxx/lib/

For example, I'm working on /opt/conda/lib/

cp /opt/conda/pkgs/libstdcxx-ng-12.1.0-ha89aaad_16/lib/libstdc++.so.6.0.30 /opt/conda/lib/
  1. Remove the old files and link the latest lib. Please repeat these steps for other folders.
cd /opt/conda/lib/
rm libstdc++.so.6.0.29
rm libstdc++.so.6.0
ln -s libstdc++.so.6.0.30 libstdc++.so.6
Fosterling answered 24/7, 2022 at 20:24 Comment(1)
Thank you so much for this answer! I have tried many other suggestions and this finally worked!Impersonal
A
22

I solved this by

conda install libgcc=5.2.0
Amidships answered 6/3, 2018 at 19:20 Comment(3)
Worked for me too. Thanks!Twobit
Worked for me as of April 26, 2020. Latest conda on that date.Midrash
libgcc is (apparently) only available in the conda-forge channel, so if you have a standard Anaconda installation, the correct command is conda install -c conda-forge libgcc=5.2.0!Aa
I
17

A solution that worked for me was:

conda install -c anaconda libstdcxx-ng

Intramolecular answered 18/5, 2020 at 11:42 Comment(2)
conda update libstdcxx-ng works for meConcubine
This worked for me! I was using scikit-image within TensorFlow for image augmentation.Unvoiced
B
6

I ran into a similar problem.

ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found 

I've solved it. Steps as follows:

try conda install -c anaconda libstdcxx-ng, // didn't work
try conda update libstdcxx-ng // didn't work too

But when I execute the command: locate libstdc++.so.6, found amazing things such as: /root/anaconda3/lib/libstdc++.so.6.0.26, which apparently is newer than .so.6.0.

I try:

strings /root/anaconda3/lib/libstdc++.so.6.0.26 | grep GLIBC
see [GLIBCXX_3.4.20][1]

That's the file I want to find.

Next step: ls -l /root/anaconda3/lib/libstdc++.so.6.0.26 - Check the file is true, not a link.

Next step: copy /root/anaconda3/lib/libstdc++.so.6.0.26 to /lib64.

Next step: ls -l /lib64/libstdc++.so.6 - It's a soft link, so I can remove it without worry.

Next step: rm -rf /lib64/libstdc++.so.6

Next step: make a new soft link by: ln -s libstdc++.so.6.0.26 libstdc++.so.6

That's all. I run my code without error.

God give me wisdom, Glory to God!

Bushing answered 21/1, 2022 at 4:13 Comment(1)
Thanks for the detailed step-by-step procedure. Worked for me to install rstudio server.Wadi
C
3

I meet the same problem, which is when I run jupyter notebook, I got

ImportError: /home/cugtyt/software/miniconda3/lib/python3.6/site-packages/zmq/backend/cython/../../../../.././libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/cugtyt/software/miniconda3/lib/python3.6/site-packages/zmq/backend/cython/../../../../../libzmq.so.5)

I solve it by doing this:

conda uninstall gcc

Hope it can help u!

Clancy answered 28/3, 2018 at 10:56 Comment(0)
S
3

I use anaconda, the following commands works for me:

conda install libgcc
export LD_LIBRARY_PATH=/path/to/anaconda/envs/myenv/lib:$LD_LIBRARY_PATH
cd /path/to/anaconda/envs/myenv/lib
ln -s libstdc++.so.6.0.30 libstdc++.so.6

you can add export LD_LIBRARY_PATH=/path/to/anaconda/envs/myenv/lib:$LD_LIBRARY_PATH to ~/.bashrc file.

Sokul answered 28/11, 2022 at 7:24 Comment(0)
S
3

I got this error for import matplotlib statement in Python. There is no need to install anything more. The reason this error occurred because this lib cannot be found on path. To fix it, add this in .bashrc:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/
Snow answered 30/9, 2023 at 9:38 Comment(0)
P
2

Ubuntu 22.04 Originally I have libstdcxx-ng=11.2.0 in my env. Then I use conda install -c conda-forge libstdcxx-ng to update it to a higher version, the problem is solved.

Pu answered 6/6, 2023 at 20:23 Comment(0)
P
0

Since libgcc=5.2.0 is not available from conda. I solve it by this:

conda uninstall cmake
pip install cmake
Panel answered 9/5, 2020 at 9:16 Comment(0)
M
0

I use mamba (a faster alternative to conda)

mamba install libgcc

Than it works.

Masse answered 20/11, 2022 at 11:58 Comment(0)
W
-1

Re-installing scipy library corrected the error automatically for me.

conda install scipy
Wey answered 6/11, 2022 at 15:40 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.