(已解决)no “render_mode“和got an unexpected keyword和No matching distribution found f

@[TOC]

前言:

清早起来,验收晚上跑的马里奥模型,一测试,发现炼丹炉爆炸了。 先后出现了 warnings.warn("You tried to call render() but no "render_mode" was passed to the env constructor.")

Box(0, 255, (4, 240, 256), uint8) observation space is not supported 等问题,下文将分析如何解决,请通读全文,再进行安装尝试!!。


问题1. render的render_mode问题

当我在运行render()的时候,遇到了这个问题 warnings.warn("You tried to call render() but no 'render_mode' was passed to the env constructor.") 意思是说你要运行render,怎么能不告诉我render_mode呢?那我们就加上。

python 复制代码
environment = gym_super_mario_bros.make('SuperMarioBros-v0',render_mode = "human")

怎么还是寄!遇到以下问题 TypeError: SuperMarioBrosEnv.__init__() got an unexpected keyword argument 'render_mode' 这就好笑了,超级玛丽的库没写render_mode而我们调用却需要!!这就十分吊诡了。 这是由于库更新了导致的,我们需要重新配置库。 笔者广阅群文,发现完全没有人说这个问题,在各种评论区畅游得到一个解决方案如下:

bash 复制代码
pip install nes-py
pip install gym-super-mario-bros==7.3.0
pip install setuptools==65.5.0 "wheel<0.40.0"
pip install gym==0.21.0
pip install stable-baselines3[extra]==1.6.0

问题2. baselines3版本问题

大喜过望,开始尝试,运行最后一个的时候

ERROR: No matching distribution found for ale-py==0.7.4; extra == "extra"

¯﹃¯ (博主当时表情) 说是缺少ale-py库,寄。于是我们再次安装ale-py==0.7.4 ????啊???0.7.4版本,他没了!¯﹃¯ 再pypl上发现官方只有8版本以上了,经过尝试,我们可以退而求其次安装

python 复制代码
pip install baselines3==1.6.0

安装成功!

问题3. cloudpickle版本问题

我们安装好了之后再次运行,之前的问题也确实没有了,又遇到了

或者NotImplementedError: Box(0, 255, (4, 240, 256), uint8) observation space is not supported 这是由于cloudpickle版本和训练版本不对应,或者cloudpickle版本不对导致的。 请卸载cloudpickle,请输入

python 复制代码
pip install cloudpickle==3.0.0

然后按照马里奥系列第三章马里奥游戏ai训练与保存重新训练与当前版本一致的模型就好啦~


完整解法

如果按照以下解法安装仍然失败,可能是由于库连体的问题,就是一些库比如baselines3和gym会附带安装其他库,请你也注意其版本,如果需要,可以删除重装。如果还是不行,建议把所有相关库删掉,然后依次执行以下代码。

py 复制代码
pip install nes-py
pip install gym-super-mario-bros==7.3.0
pip install setuptools==65.5.0 "wheel<0.40.0"
pip install gym==0.21.0
pip install stable-baselines3==1.6.0
pip install cloudpickle==3.0.0

如果还是不行,我附上我的各个库的版本(相关的),请根据自己的需要查看。输入pip list 即可查看自己的库。这些库的版本如果都对,是可以运行render之类的显示指令的。请一一对应检查。

c 复制代码
ale-py                     0.8.1
atari-py                   0.2.6
cloudpickle                3.0.0
gym                        0.21.0
gym-notices                0.0.8
gym-super-mario-bros       7.3.0
gymnasium                  0.28.1
importlib-metadata         4.13.0
importlib_resources        6.4.0
MarkupSafe                 2.1.3
matplotlib                 3.8.2
matplotlib-inline          0.1.6
nes-py                     8.2.1
numpy                      1.26.0
opencv-contrib-python      4.9.0.80
opencv-python              4.9.0.80
pip                        24.0
pygame                     2.5.2
setuptools                 65.5.0
Shimmy                     1.3.0
tensorboard                2.16.2
tensorboard-data-server    0.7.2
tensorboardX               2.6.2.2
torch                      2.1.2+cu118
torchaudio                 2.1.2+cu118
torchvision                0.16.2+cu118
wheel                      0.38.4

相关推荐
机器之心5 分钟前
京东卷出新高度!硬刚「复杂指令」长时长、自由态数字人直播终于丝滑了
人工智能·openai
机器之心5 分钟前
龙虾太难养?发布的SOLO独立端,可能是你要的AI生产力
人工智能·openai
nancy_princess25 分钟前
attention基础概念1
人工智能
做个文艺程序员26 分钟前
华为昇腾NPU部署开源大模型全攻略(以Qwen3-8B为例)
人工智能·深度学习·华为
智算菩萨1 小时前
【论文精读】Automated machine learning for positive-unlabelled learning
论文阅读·人工智能·机器学习·论文笔记·贝叶斯优化·自动机器学习·无标签学习
小程故事多_801 小时前
破解Agent“半途摆烂”困局,OpenDev凭Harness架构,撕开Code Agents的工程化真相
人工智能·架构·aigc·harness
吴佳浩1 小时前
Vibe Coding 时代:Vue 消失了还是 React 太强?
人工智能
Elastic 中国社区官方博客1 小时前
Elasticsearch:如何在 Elastic AI Builder 里使用 DSL 来查询 Elasticsearch
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索
musicml1 小时前
从 Vibe Coding 到 SDD(规范驱动开发):AI 原生时代的软件工程化实践
人工智能·驱动开发·软件工程
Deepoch1 小时前
Deepoc具身模型:重塑无人机无遥控器作业
人工智能·科技·无人机·具身模型·deepoc