# unitree_sdk2_python安装报错Could not locate cyclonedds

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-01-16-unitree-sdk2-python-98
> 频道：pitfalls | 更新日期：2026-01-16 | 标签：auto, github-issue, unitree_sdk2_python
> 核心摘要：构建cyclonedds Python绑定失败因缺少0.10.x C库，需源码编译Cyclone DDS并配置环境变量后重装。

# unitree_sdk2_python安装报错Could not locate cyclonedds

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[pip install error under mac](https://github.com/unitreerobotics/unitree_sdk2_python/issues/98)（GitHub unitreerobotics/unitree_sdk2_python #98）

**状态**：已解决

## 问题

在Mac或DevContainer中执行pip install -e .安装unitree_sdk2_python时，构建cyclonedds==0.10.2 wheel失败，报错subprocess-exited-with-error及Could not locate cyclonedds. Try to set CYCLONEDDS_HOME or CMAKE_PREFIX_PATH。

## 环境

OS: macOS / Ubuntu 22.04 (DevContainer/aarch64); Python: 3.10/3.13; unitree_sdk2_python: 1.0.1; 依赖: cyclonedds==0.10.2

## 解决办法

1. 从源码编译安装Cyclone DDS 0.10.x C库：创建build目录，执行cmake .. -DCMAKE_INSTALL_PREFIX=../install && cmake --build . --target install -j$(nproc)，确保生成include与lib目录。
2. 设置环境变量指向编译产物：export CYCLONEDDS_HOME=/path/to/install 或 export CMAKE_PREFIX_PATH=/path/to/install，使pip构建时能定位到正确版本的头文件与库。
3. 重新执行pip install cyclonedds==0.10.2及pip install -e .安装unitree_sdk2_python，验证导入无ModuleNotFoundError。
4. 避免使用系统包管理器安装的旧版cyclonedds-dev，因其API与头文件不兼容0.10.x Python绑定构建需求。

讨论原作者：@zzz6519003 等，版权归原作者所有。
:::

## 原始参考来源 (Sources)

- [GitHub unitreerobotics/unitree_sdk2_python #98：pip install error under mac](https://github.com/unitreerobotics/unitree_sdk2_python/issues/98)