'Anaconda ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found
I am getting the following import error when I am trying to run a Python script in a conda environment
(squad) azada@scholar-fe00:~/Desktop/Toy-Problem-Team-2 $ python3 train.py
Traceback (most recent call last):
File "train.py", line 21, in <module>
from tensorboardX import SummaryWriter
File "/home/azada/miniconda3/envs/squad/lib/python3.6/site-packages/tensorboardX/__init__.py", line 5, in <module>
from .torchvis import TorchVis
File "/home/azada/miniconda3/envs/squad/lib/python3.6/site-packages/tensorboardX/torchvis.py", line 11, in <module>
from .writer import SummaryWriter
File "/home/azada/miniconda3/envs/squad/lib/python3.6/site-packages/tensorboardX/writer.py", line 15, in <module>
from .event_file_writer import EventFileWriter
File "/home/azada/miniconda3/envs/squad/lib/python3.6/site-packages/tensorboardX/event_file_writer.py", line 28, in <module>
from .proto import event_pb2
File "/home/azada/miniconda3/envs/squad/lib/python3.6/site-packages/tensorboardX/proto/event_pb2.py", line 7, in <module>
from google.protobuf import descriptor as _descriptor
File "/home/azada/miniconda3/envs/squad/lib/python3.6/site-packages/google/protobuf/descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/azada/miniconda3/envs/squad/lib/python3.6/site-packages/google/protobuf/pyext/_message.cpython-36m-x86_64-linux-gnu.so)
Writing the strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
command has the following output
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_DEBUG_MESSAGE_LENGTH
As you can see the required libgcc
version is not present. But I am unable to understand why python is looking for GLIBCXX
in the /usr
directory?
Running the same command on the libstdc++.so.6
of my anaconda environment shows that the required version is present in the file.
I am using my university's computing cluster so I don't have the admin rights.
Is there any way that I can make Python use the libstdc++
of my conda environment instead of the one in the /usr
directory?
Solution 1:[1]
I spent a day working on this having encountered the same exact problem working on my research university's computing cluster with the same specs as you, and I finally found the right Stack Overflow thread. None of the above answers here work, unfortunately, but I can say with very high confidence that the details in the linked thread should solve your problem even though the source of the error traceback was different.
To summarize, you'll need to add the path to the lib
folder in anaconda
to LD_LIBRARY_PATH
:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/path/to/conda/env/lib
In my case, I just did:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/anaconda3/lib
...and it worked like a charm!
Solution 2:[2]
solve it by downgrading to libgcc==5.2.0
Initially, try to install with pip but if you get the error: Could not download and compile the C core of igraph.. install it by conda
Solution 3:[3]
Run this code and your problem should be solved,
conda install -c conda-forge gcc
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Yassine HAMDAOUI |
Solution 3 | Mushfirat Mohaimin |