You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

mlagents-learn --help在多Python版本下执行均报错的问题求助

mlagents-learn --help在多Python版本下执行均报错的问题求助

各位好,我最近在安装mlagents时碰到了一个头疼的问题,换了好几个Python版本尝试都没能解决,想请大家帮忙看看。

我的操作流程大概是这样的:

  • 用pyenv-win创建虚拟环境,先后把本地Python版本设置为3.8、3.9、3.10、3.11,每个版本都单独试过
  • 升级了pip到最新版本,接着依次安装了mlagents、torch、torchvision和torchaudio
  • 第一次运行mlagents-learn --help时出现错误,于是我安装了protobuf 3.20.3,但再次运行命令还是报错
  • 之后我又尝试把cattrs降级到1.5.0版本,可问题依然存在

下面是我运行mlagents-learn --help时得到的报错信息:

(venv) D:\Unity\AI Ecosystem>mlagents-learn --help
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\Unity\AI Ecosystem\venv\Scripts\mlagents-learn.exe\__main__.py", line 4, in <module>
  File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\trainers\learn.py", line 2, in <module>
    from mlagents import torch_utils
  File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\torch_utils\__init__.py", line 1, in <module>
    from mlagents.torch_utils.torch import torch as torch  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\torch_utils\torch.py", line 6, in <module>
    from mlagents.trainers.settings import TorchSettings
  File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\trainers\settings.py", line 644, in <module>
    class TrainerSettings(ExportableSettings):
  File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\mlagents\trainers\settings.py", line 667, in TrainerSettings
    cattr.register_structure_hook(
  File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\cattr\converters.py", line 207, in register_structure_hook
    self._structure_func.register_cls_list([(cl, func)])
  File "D:\Unity\AI Ecosystem\venv\Lib\site-packages\cattr\dispatch.py", line 55, in register_cls_list
    self._single_dispatch.register(cls, handler)
  File "C:\Users\Ebrah\AppData\Local\Programs\Python\Python311\Lib\functools.py", line 864, in register
    raise TypeError(
TypeError: Invalid first argument to `register()`. typing.Dict[mlagents.trainers.settings.RewardSignalType, mlagents.trainers.settings.RewardSignalSettings] is not a class or union type.

补充一下我的环境信息:

  • Unity版本:2022.3.5f1
  • pyenv版本:3.1.1
  • 操作系统:Windows 11
  • 使用的是pyenv-win来管理Python版本

有没有朋友遇到过类似的问题?或者能给我一些排查方向的建议?非常感谢!

备注:内容来源于stack exchange,提问作者Joemama

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 17:25:25