EDIT: When i remove render_mode="rgb_array"
it works fine. But this obviously is not a real solution.
I am trying to run a render of a game in Jupyter notebook but each time i run it i get a pop up saying Python 3.7 crashed
and the kernel has died.
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import time
import gym
from gym.envs.registration import register
from IPython.display import clear_output
try:
register(
id='FrozenLakeNotSlippery-v0', #Name this whatever you want
entry_point='gym.envs.toy_text:FrozenLakeEnv',
kwargs={'map_name' : '4x4', 'is_slippery': False},
max_episode_steps=100,
reward_threshold=0.78, # optimum = .8196
)
except:
print("Already Registered")
env = gym.make("FrozenLakeNotSlippery-v0",render_mode='rgb_array')
env.reset()
for step in range(5):
env.render()
action = env.action_space.sample()
observation, reward, terminated, truncated, info = env.step(action)
time.sleep(0.5)
print(observation)
clear_output(wait=True)
if terminated:
env.reset()
env.close()
Above is the code I have. Its very straight forward and seems to be a known issue, though I haven't seen anyone have any solutions.
I have tried uninstalling and then re-installing the following packages with pip install:
I ave found the issue: if you look at the source code for frozen_lake
, it only accepts a render_mode
of 'human'
& 'ansi'
:
metadata = {'render.modes': ['human', 'ansi']}
so a render_mode="rgb_array"
, as in my case above, will produce an error.