42

I am trying to import librosa, but I am thrown with this error:

/home/lakshya/anaconda3/envs/tff_env/lib/python3.9/site-packages/zmq/backend/cython/../../../../.././libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/lakshya/anaconda3/envs/tff_env/lib/python3.9/site-packages/scipy/fft/_pocketfft/pypocketfft.cpython-39-x86_64-linux-gnu.so)

I tried the following to fix it based on the other similar questions that I browsed through:

  1. sudo apt-get install libstdc++6

    It's output: libstdc++6 is already the newest version (10.2.1-6).

  2. sudo apt-get dist-upgrade

    It's output: 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

  3. strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX

    It's output: GLIBCXX version up to GLIBCXX_3.4.28

  4. conda install libgcc in my virtual env "tff_env"

    It's output: libgcc-7.2.0 installed in tff_env

  5. Pip installed the libgcc package in the virtual environment as well. Didn't work.

What can I do?

My OS: Debian GNU/Linux 11 (bullseye)

ChaoS Adm
  • 715
  • 1
  • 5
  • 12
  • It looks like you somehow ended up with `scipy` built with a newer version of gcc than you have installed by default. Do you have other versions of gcc installed somewhere on your system? (libgcc version is irrelevant, don't bother with it). – n. m. could be an AI Jun 08 '22 at 07:17
  • 1
    I just installed Debian 11 2 days back. I haven't explicitly installed any gcc separately. The one thing I did was install Python3.10 using `make altinstall` and Anaconda. Then within the conda environment "tff_env" I installed tensorflow-federated. How do I check if I have other gcc versions somewhere? Or perhaps downgrade scipy so it doesn't need the gcc version that I don't have? – ChaoS Adm Jun 08 '22 at 07:23
  • I am not entirely familiar with how anaconda works, does it build binaries locally or download forom somewhere? If the latter, there is a gap, as it downloaded a version that won't run on your system. Not sure how to deal with it. I personally try to always install the latest available gcc/g++/libraries to avoid this kind of problem and to have the latest set of features. Try either installing g++12 or downgrading your packages (but you may have to downgrade a lot). Also, avoid installing from source with `make install` and the like. If you need Python10, find a package for it. – n. m. could be an AI Jun 08 '22 at 08:19

10 Answers10

57

Just been tackling a similar problem, it looks like you need to ensure you have the latest version of gcc. Running:

conda install -c conda-forge gcc=12.1.0

Fixed the error for me.

dfcorbin
  • 686
  • 3
  • 4
18

After my search on anaconda packages, I found only the package "libstdcxx" will substantially bring new "libstdc++.so.6" file to the conda environment (while "gcc", "gcc_linux-64", and "libgcc-ng" cannot). Thus, installing the following package can fix this problem for me.

conda install -c conda-forge libstdcxx-ng=12

PS: dfcorbin's answer conda install -c conda-forge gcc=12 not works for me.

Nico
  • 403
  • 3
  • 8
11

If the accepted answer didn't work, try this

I had the same conditions as the original poster and the accepted answer didn't work as conda was taking forever. I tried down-versioning scipy from 1.9.3 to 1.9.1 and it did work.

You can use the following command to do so:

conda install -c anaconda scipy==1.9.1 
Anwarvic
  • 12,156
  • 4
  • 49
  • 69
10

None of the above answers worked for me, unfortunately. What I ended up doing was to manually inspect the libstdc++.so.6 file.

First, I checked the system file, and it returned nothing on my side:

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX_3.4.30

Then, I took a look the conda file, and it was there:

strings /path-to-your-conda/envs/your-env-name/lib/libstdc++.so.6 | grep GLIBCXX_3.4.30

This indicates that the simple solution is to append the path to the conda file to the LD_LIBRARY_PATH.

export LD_LIBRARY_PATH=/path-to-your-conda/envs/your-env-name/lib:$LD_LIBRARY_PATH

Kai
  • 111
  • 1
  • 3
  • 1
    I was looking to install a different program but running into the same issue, and no solution worked for me EXCEPT this one. Thanks so much for posting! – Adam Jun 29 '23 at 20:18
6

One solution that fixed this problem for while trying to run mujoco or mujoco-py was as follows

OSError: /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not foundwhen starting ipython. For some reason this library isnt in the anaconda environments libstdc++.so.6. It is in the base ubuntu library. So link the anaconda version of this library back to the os version:

cd /home/ubuntu/anaconda3/envs/tensorflow_p36/lib
mv libstdc++.so.6 libstdc++.so.6.old
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6

credits: https://bcourses.berkeley.edu/courses/1478831/pages/glibcxx-missing

bmg
  • 121
  • 1
  • 3
  • 5
  • Yeah, basically used this same approach on another program (not related to "conda"). Sometimes a program gets shipped and packaged with a older version of a library (e.g. "libstdc++"), but a second program that *interfaces* with that first program expects the first program to have a more up-to-date version of the library. Assuming there are no breaking changes in the newer library version, this approach should work just fine--just be *sure* to back up the older library version (e.g. append ".old") just in case. – JustALawnGnome7 Nov 30 '22 at 19:11
2

So what worked for me was to manually remove Python3.10 which I had installed using make altinstall and upgrade scipy to the latest version.

ChaoS Adm
  • 715
  • 1
  • 5
  • 12
1

None of the other answers worked for me. This did work though:

pip install scikit-build
0

In some cases, there exist multiple installations of glibcxx and runtime your app wants to connect to it but finds the library in the wrong place. It can be solved by changing the imported libraries' order. The problem has been solved by importing librosa on top of the running script.

0

None of the other answers worked for me, but this solved the problem:

import torch

The line is to add in top of file.

vox7
  • 1
  • 1
-1

The soln given above doesn't work for me. I got it working by downgrading my scipy from 1.9.1 to 1.6.1.

quarkz
  • 111
  • 7