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

安装gym-super-mario-bros后运行程序报ValueError: not enough values to unpack (expected 5, got 4)

解决gym-super-mario-bros运行时的ValueError问题

这个错误是由于gym-super-mario-bros与依赖的nes-py版本不兼容导致的——新版本nes-py的环境step()方法返回值从5个改成了4个,但旧版gym-super-mario-bros仍期望接收5个值,从而触发解包错误。

修复步骤:

  1. 卸载现有冲突版本
pip uninstall -y gym-super-mario-bros nes-py
  1. 安装指定兼容版本
    先安装稳定兼容的nes-py版本,再安装gym-super-mario-bros:
pip install nes-py==8.2.1
pip install gym-super-mario-bros
  1. 验证修复
    运行以下测试代码确认问题解决:
import gym_super_mario_bros
from nes_py.wrappers import JoypadSpace
from gym_super_mario_bros.actions import SIMPLE_MOVEMENT

# 创建游戏环境
env = gym_super_mario_bros.make('SuperMarioBros-v0')
env = JoypadSpace(env, SIMPLE_MOVEMENT)

done = True
for _ in range(1000):
    if done:
        state = env.reset()
    # 执行随机动作
    state, reward, done, info = env.step(env.action_space.sample())
    env.render()

env.close()

内容的提问来源于stack exchange,提问作者Pranav Joshi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.05 07:50:11