Bootstrap

ImportError: zstd C API versions mismatch 的参考解决方法

写在前面

自己的测试环境:
Ubuntu20.04
ROS-Noetic

一、问题描述

自己运行 python 程序时出现如下报错:

  File "/home/wong/.local/lib/python3.8/site-packages/evo/tools/file_interface.py", line 34, in <module>
    from rosbags.rosbag2 import (Reader as Rosbag2Reader, Writer as Rosbag2Writer)
  File "/home/wong/.local/lib/python3.8/site-packages/rosbags/rosbag2/__init__.py", line 11, in <module>
    from .reader import Reader
  File "/home/wong/.local/lib/python3.8/site-packages/rosbags/rosbag2/reader.py", line 11, in <module>
    import zstandard
  File "/home/wong/.local/lib/python3.8/site-packages/zstandard/__init__.py", line 39, in <module>
    from .backend_c import *  # type: ignore
ImportError: zstd C API versions mismatch; Python bindings were not compiled/linked against expected zstd version (10404 returned by the lib, 10502 hardcoded in zstd headers, 10502 hardcoded in the cext)

在这里插入图片描述

二、解决方法

出现上述版本的原因是 zstandard 或者 zstd 未安装,或者版本太老了。重新安装zstandard 或者 zstd 即可解决问题。

pip install --force-reinstall zstandard zstd

然后再次执行 python 程序即可。

参考链接

[1] PHPirate. Conda not working after reinstall - zstandard issue [EB/OL]. https://stackoverflow.com/questions/76266770/conda-not-working-after-reinstall-zstandard-issue, 2023-10-22/2024-08-26.

;