(已解决)no “render_mode“和got an unexpected keyword和No matching distribution found for ale-py==0.7.4终极解法

前言:

清早起来,验收晚上跑的马里奥模型,一测试,发现炼丹炉爆炸了。
先后出现了
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呢?那我们就加上。

environment = gym_super_mario_bros.make('SuperMarioBros-v0',render_mode = "human")

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

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版本以上了,经过尝试,我们可以退而求其次安装

pip install baselines3==1.6.0

安装成功!

问题3. cloudpickle版本问题

我们安装好了之后再次运行,之前的问题也确实没有了,又遇到了
在这里插入图片描述

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

pip install cloudpickle==3.0.0

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


完整解法

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

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之类的显示指令的。请一一对应检查。

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

  • 31
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值