16

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

James Z
  • 12,209
  • 10
  • 24
  • 44
user8523104
  • 467
  • 1
  • 3
  • 14
  • 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. – Knud Larsen Jan 26 '18 at 01:07
  • 1
    I could solve this problem by removing and installing Anaconda after a lot of effort that I could not solve it. thanks for your comment – user8523104 Jan 26 '18 at 19:06

10 Answers10

21

I solved this by

conda install libgcc=5.2.0
ceiling cat
  • 5,501
  • 9
  • 38
  • 51
13

A solution that worked for me was:

conda install -c anaconda libstdcxx-ng

pebox11
  • 3,377
  • 5
  • 32
  • 57
13

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
Wenning Lin
  • 131
  • 1
  • 4
4

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!

ouflak
  • 2,458
  • 10
  • 44
  • 49
Frame Li
  • 41
  • 3
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!

user9563571
  • 591
  • 4
  • 3
1

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.

1

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.

0

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

conda uninstall cmake
pip install cmake
0

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

conda install scipy
0

I use mamba (a faster alternative to conda)

mamba install libgcc

Than it works.