使用gym中的录制功能,报错,具体:
>>> import gym
>>> gym.wrappers.Monitor
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'gym.wrappers' has no attribute 'Monitor'
经过网上查询知道在gym的0.21以上版本API进行了更改,gym.wrappers.Monitor由
gym.wrappers.RecordVideo 和 gym.wrappers.RecordEpisodeStatistics 所替代:
注意,使用之前需要安装依赖:
pip install moviepy
import gym env = gym.make("BipedalWalker-v3",render_mode = 'human') env = gym.wrappers.RecordEpisodeStatistics(env) env = gym.wrappers.RecordVideo(env, f"videos/{gym.__version__}")
===================================================
参考: