Search code examples
pythonreinforcement-learningopenai-gym

NameError: name 'env' is not defined


I am trying to train a model to solve the FrozenLake-v0 problem.

In the process am trying to instantiate the environment in the following way. But encountering an error. Please help me with this

!apt install xvfb -y
!pip install pyvirtualdisplay
!pip install piglet

from pyvirtualdisplay import Display
pip install gym
import torch
import time
import matplotlib.pyplot as plt
pip install pyglet
env = gym.make('FrozenLake-v0')

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-13-3d8d6ba4b349> in <module>()
----> 1 env = gym.make('FrozenLake-v0')

NameError: name 'gym' is not defined

Solution

  • You have not add import gym in the beginning...