I am trying to implement simple cart pole code but pygame window doesnt close on env.close and freezes. When i try to manually close, it is restarting kernel. This is my code :
env = gym.make("CartPole-v1", render_mode = "human")
episodes = 5
for episode in range(1, episodes+1):
state = env.reset()
done = False
score = 0
while not done:
env.render()
action = env.action_space.sample()
n_state, reward, done,truncated, info = env.step(action)
score += reward
print("Episode:{} Score: {}".format(episode, score))
env.close()
I tried to declera env in different cell but nothing changed. I tried to uninstall and reinstall the packages but it same again. Anyone can help ?