NameError: name 'env' is not defined

NameError: name 'env' is not defined

我正在尝试训练一个模型来解决 FrozenLake-v0 问题。

在此过程中,我尝试通过以下方式实例化环境。但是遇到错误。请帮我解决这个问题

!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

你没有在开头添加import gym...