[英]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当我尝试在 conda 环境中运行 Python 脚本时出现以下导入错误
(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
编写
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
command has the following output strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
命令有以下 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.如您所见,所需的
libgcc
版本不存在。 But I am unable to understand why python is looking for GLIBCXX
in the /usr
directory?但我无法理解为什么 python 在
/usr
目录中寻找GLIBCXX
?
Running the same command on the libstdc++.so.6
of my anaconda environment shows that the required version is present in the file.在我的 anaconda 环境的
libstdc++.so.6
上运行相同的命令表明文件中存在所需的版本。
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?有什么方法可以让 Python 使用我的 conda 环境的
libstdc++
而不是/usr
目录中的那个?
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 .我花了一天的时间来解决这个问题,在我的研究型大学的计算集群上工作时遇到了与你相同的问题,我终于找到了正确的 Stack Overflow 线程。 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
:总而言之,您需要将
anaconda
中lib
文件夹的路径添加到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! ......它就像一个魅力!
solve it by downgrading to libgcc==5.2.0通过降级到 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最初,尝试使用 pip 安装,但如果出现错误:无法下载和编译 igraph 的 C 核心。通过conda安装
conda install -c conda-forge gcc conda install -c conda-forge gcc
This is because you have some old versions not cleaned up while upgrading gcc.这是因为您在升级 gcc 时没有清理一些旧版本。
find / -name "libstdc++.so*"
.find / -name "libstdc++.so*"
查找所有 lib 版本。 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
/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
/opt/conda/envs/xxx/lib/
or /opt/conda/lib
/opt/conda/envs/xxx/lib/
或/opt/conda/lib
For example, I'm working on /opt/conda/lib
例如,我正在研究
/opt/conda/lib
cp /opt/conda/pkgs/libstdcxx-ng-12.1.0-ha89aaad_16/lib/libstdc++.so.6.0.30 /opt/conda/lib
cd /opt/conda/lib
rm libstdc++.so.6.0
ln -s libstdc++.so.6.0.30 libstdc++.so.6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.