Windows 基于 Pixi 源码编译 ROS2 Lyrical,解决 RoboStack rqt WinError 193 问题
摘要:Windows 使用 RoboStack 预编译 ROS2 Lyrical 时,rqt 系列 Python GUI 工具会抛出
WinError 193 %1 不是有效的 Win32 应用程序,属于上游打包硬缺陷。本文使用 ROS 核心维护者 Chris Lalancette 提供的 pixi 构建清单,仅针对 Windows 平台源码编译,预置 Qt6 插件路径,编译后 rqt_gui、rqt_graph、rviz2 均可正常启动。 标签:ROS2;Lyrical;Windows;Pixi;rqt;rviz2
一、问题背景
在 Windows 上使用 RoboStack + Pixi 部署 ROS2 Lyrical 会遇到一个很头疼的问题:
- ✅ C++ 程序:rviz2、talker、listener、
ros2 topic/service/bag等命令行功能全部正常 - ❌ 所有 rqt 图形工具:执行
ros2 run rqt_gui rqt_gui直接报错WinError 193
根本原因:RoboStack Windows 打包时,rqt 的 Python 入口只有 Unix shebang 脚本,没有 Windows 可执行包装器,Windows 无法直接把纯文本脚本当做程序运行,该缺陷在 RoboStack 当前版本没有简单补丁方案。
可选方案对比:
- 继续 RoboStack:放弃 rqt,仅使用 rviz + 命令行调试
- OSRF 官方预编译 zip:内置包有限,很多功能包需要自行补充
- Pixi + 源码编译(本文方案):官方原生构建环境,Qt 路径预先配置,编译后 rqt 全家桶正常可用,自由度最高
二、前置条件
- 安装 Pixi:https://pixi.sh/
- 网络可以访问 GitHub,用于拉取 ROS2 源码
- 磁盘预留 20GB 以上空间,编译耗时 30–60 分钟(取决于 CPU 性能)
- Windows10/11,建议开启开发者模式
三、pixi.toml(仅 Windows 精简版)
新建工作目录,在目录中创建 pixi.toml,下面是裁剪掉 Linux 配置、只保留 win-64 的清单:
[workspace]
name = "pixi_ros2_lyrical"
version = "0.1.0"
description = "Build ROS 2 Lyrical on Windows with pixi"
authors = ["Chris Lalancette <clalancette@gmail.com>"]
channels = ["conda-forge"]
platforms = ["win-64"]
[target.win-64.dependencies]
7zip = ">=23.1,<24"
osrf_pycommon = "==0.2.1"
pyqt6 = ">=6.7,<7"
pyqt6-sip = ">=13.0,<14"
[target.win-64.activation.env]
# Qt6平台插件路径,解决Windows Qt GUI加载失败
QT_QPA_PLATFORM_PLUGIN_PATH="%CONDA_PREFIX%\\Library\\lib\\qt6\\plugins\\platforms"
[dependencies]
colcon-cmake = ">=0.2.28,<0.3"
colcon-core = ">=0.17.1,<0.18"
colcon-defaults = ">=0.2.8,<0.3"
colcon-library-path = ">=0.2.1,<0.3"
colcon-metadata = ">=0.2.5,<0.3"
colcon-mixin = ">=0.2.3,<0.3"
colcon-output = ">=0.2.13,<0.3"
colcon-package-information = ">=0.4.0,<0.5"
colcon-package-selection = ">=0.2.10,<0.3"
colcon-parallel-executor = ">=0.2.4,<0.3"
colcon-pkg-config = ">=0.1.0,<0.2"
colcon-powershell = ">=0.4.0,<0.5"
colcon-python-setup-py = ">=0.2.7,<0.3"
colcon-recursive-crawl = ">=0.2.3,<0.3"
colcon-ros = ">=0.5.0,<0.6"
colcon-ros-domain-id-coordinator = ">=0.2.1,<0.3"
colcon-test-result = ">=0.3.8,<0.4"
argcomplete = "==3.1.4"
asio = "==1.28.1"
assimp = "==5.3.1"
benchmark = "==1.8.3"
bullet = "==3.25"
catkin_pkg = "==1.0.0"
cli11 = "==2.4.1"
clang-tools = "==18.1.8"
cmake = "==3.28.3"
console_bridge = "==1.0.1"
coverage = "==7.4.4"
cppcheck = "==2.15.0"
cryptography = "==41.0.7"
cunit = "==2.1.3"
curl = ">=8.5,<9"
distlib = "==0.3.8"
docutils = "==0.20.1"
eigen = "==3.4.0"
empy = "==3.3.4"
flake8 = "==7.0.0"
flake8-blind-except = "==0.2.1"
flake8-builtins = "==2.1.0"
flake8-class-newline = "==1.6.0"
flake8-comprehensions = "==3.14.0"
flake8-deprecated = "==2.2.1"
flake8-import-order = "==0.18.2"
flake8-quotes = "==3.4.0"
freetype = "==2.13.3"
git = ">=2.43.0"
gmock = "==1.17.0"
graphviz = "==9.0.0"
gtest = "==1.17.0"
importlib-metadata = "==4.13.0"
iniconfig = "==1.1.1"
lark = "==1.1.9"
libcurl = ">=8.5.0,<9"
lxml = "==5.2.1"
lz4-c = "==1.9.4"
mccabe = "==0.7.0"
mypy = "==1.9.0"
mypy_extensions = "==1.0.0"
nlohmann_json = "==3.11.3"
numpy = "==1.26.4"
opencv = "==4.10.0"
openssl = ">=3.4,<4"
orocos-kdl = "==1.5.1"
osrf_pycommon = "==0.2.1"
packaging = "==24.0"
pathspec = "==0.12.1"
pip = "==24.0"
pluggy = "==1.4.0"
psutil = "==5.9.8"
pybind11 = "==2.11.1"
pycodestyle = "==2.11.1"
pydantic = "==1.10.14"
pydocstyle = "==6.3.0"
pydot = "==1.4.2"
pyflakes = "==3.2.0"
pygraphviz = "==1.11"
pyparsing = "==3.1.1"
pytest = "==7.4.4"
pytest-asyncio = "==0.20.3"
pytest-cov = "==4.1.0"
pytest-mock = "==3.12.0"
pytest-repeat = "==0.9.3"
pytest-rerunfailures = "==12.0"
pytest-runner = "==6.0.0"
pytest-timeout = "==2.2.0"
python = "==3.12.3"
python-dateutil = "==2.8.2"
python-fastjsonschema = "==2.19.0"
python-orocos-kdl = "==1.5.1"
pyyaml = "==6.0.1"
qt6-main = ">=6,<7"
rosdistro = "==1.0.0"
rust = "==1.93.0"
setuptools = "==68.1.2"
six = "==1.16.0"
snowballstemmer = "==2.2.0"
spdlog = "==1.12.0"
sqlite = ">=3.47,<4"
tinyxml2 = "==10.0.0"
types-pyyaml = "==6.0.1"
typing_extensions = "==4.10.0"
uncrustify = "==0.78.1"
vcstool = "==0.3.0"
yaml-cpp = "==0.8.0"
yamllint = "==1.33.0"
yaml = "==0.2.5"
zipp = "==1.0.0"
zstd = "~=1.5.5"
四、构建步骤
1. 安装依赖环境
在当前目录打开 CMD,执行:
pixi install
Pixi 自动从 conda-forge 拉取全部编译依赖:Qt6、Python3.12、CMake、colcon 工具链等。
2. 进入隔离构建环境
pixi shell
进入环境时自动设置
QT_QPA_PLATFORM_PLUGIN_PATH,这是 GUI 正常加载的关键。
3. 拉取 ROS2 Lyrical 源码
准备官方 lyrical.repos 文件,然后执行导入:
mkdir src
vcs import src < lyrical.repos
4. colcon 编译(merge-install 规避 Windows 长路径坑)
colcon build --merge-install
Windows 强烈推荐
--merge-install,大幅缩短路径长度,避开 Windows 路径长度限制报错。
5. 加载编译好的 ROS 环境
call install\setup.bat
五、功能验证(重点:rqt 不再报 193)
# 启动 rviz2
ros2 run rviz2 rviz2
# rqt 主界面(RoboStack此处报错,源码编译版正常弹出窗口)
ros2 run rqt_gui rqt_gui
# 话题关系图
ros2 run rqt_graph rqt_graph
# 消息收发测试
ros2 run demo_nodes_cpp talker
ros2 run demo_nodes_py listener
rviz 默认告警
No tf data. Actual error: Frame [map] does not exist属于正常现象,只是没有坐标系变换广播。 测试静态 TF 变换命令:
ros2 run tf2_ros static_transform_publisher 0 0 0 0 0 0 map base_link
在 rviz 添加 TF Display 插件,即可可视化坐标系。
六、RoboStack 与 Pixi 源码编译对比
表格
| 项目 | RoboStack 预编译包 | Pixi 源码编译 |
|---|---|---|
| 部署方式 | pixi add 直接拉二进制 | vcs 拉源码 + colcon build |
| rqt 状态 | ❌ WinError 193,无法启动 | ✅ 原生正常 |
| 耗时 | 秒级 | 半小时左右 |
| 可定制性 | 低,包版本由上游打包决定 | 高,可修改源码、裁剪功能包 |
| Qt 配置 | 缺少 Windows 启动包装 | 预置 Qt6 平台插件路径 |
七、排错与注意事项
WARN ignoring SSL_CERT_DIR:证书目录缺失警告,不影响 ROS 运行和 GUI 启动,可以直接忽略;vcs import拉取超时:单独 git clone 失败的仓库放到 src 目录;- 编译报错优先检查磁盘空间、路径是否过长;
- 编译成功后,每次新开终端都要执行
pixi shell+call install\setup.bat。
八、小结
如果只是跑 rviz、C++ 算法节点,RoboStack 足够省事。一旦需要 rqt_graph、rqt_console 这类调试工具,RoboStack 的 Windows 打包缺陷很难绕过。采用 ROS 官方维护的 pixi 清单源码编译,是 Windows 平台跑全套 ROS2 Lyrical GUI 工具稳定可靠的方案。
参照资料:
- [conda-forge | community-driven packaging for conda](https://conda-forge.org/)
- [ROS: Getting Started](https://www.ros.org/blog/getting-started/#)
- [Installation — ROS 2 Documentation: Lyrical documentation](https://docs.ros.org/en/lyrical/Get-Started/Installation.html)
- [Installing on Windows (binary) - how-to — ROS 2 Documentation: Lyrical documentation](https://docs.ros.org/en/lyrical/Get-Started/Installation/Windows-Install-Binary.html)
- [Installing on Windows (source) - how-to — ROS 2 Documentation: Lyrical documentation](https://docs.ros.org/en/lyrical/Get-Started/Installation/Alternatives/Windows-Development-Setup.html)

浙公网安备 33010602011771号