# Windows下MuJoCo加载含UTF-8字符路径XML报错ParseXML

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-11-03-mujoco-3139
> 频道：pitfalls | 更新日期：2026-11-03 | 标签：auto, github-issue, mujoco
> 核心摘要：Windows环境MuJoCo因fopen默认ANSI编码无法加载UTF-8路径文件，通过替换为_wfopen宽字符接口修复。

# Windows下MuJoCo加载含UTF-8字符路径XML报错ParseXML

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[MuJoCo files in a directory containing UTF-8 fail to load (Windows only)](https://github.com/google-deepmind/mujoco/issues/3139)（GitHub google-deepmind/mujoco #3139）

**状态**：已解决

## 问题

在Windows 11下使用MuJoCo 3.5.0的bin/simulate.exe或Python API mujoco.MjSpec.from_file加载位于含日文/中文等UTF-8字符目录中的XML文件时，报错ParseXML: Error opening file且路径乱码。该问题仅出现在Windows平台，Linux环境正常。

## 环境

MuJoCo 3.5.0, Python 3.11.13, Windows 11, bin/simulate.exe

## 解决办法

1. 定位MuJoCo源码中6处处理用户路径的fopen调用。
2. 实现_wfopen宽字符包装函数替代原生fopen，以支持Windows UTF-8路径解析。
3. 应用PR #3155补丁并重新编译MuJoCo。
4. 验证simulate.exe及Python接口可正常加载UTF-8路径下的XML及其引用的stl/obj资源文件。

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

## 原始参考来源 (Sources)

- [GitHub google-deepmind/mujoco #3139：MuJoCo files in a directory containing UTF-8 fail to load (Windows only)](https://github.com/google-deepmind/mujoco/issues/3139)