stable_baselines module error -> ‘gym.logger’ has no attribute ‘MIN_LEVEL’

原文标题stable_baselines module error -> ‘gym.logger’ has no attribute ‘MIN_LEVEL’

我正在尝试使用 stable_baselines,但我尝试使用的任何模型都会给我同样的错误:

模块“gym.logger”没有属性“MIN_LEVEL”

我附上了他们网站上的一个例子,它给了我同样的错误。我尝试在网上查找,但没有任何成功。另外,我目前正在使用 Conda 创建具有以下设置的环境。

张量流:1.15.0Python:3.7.11

代码如下。

import gym

from stable_baselines.common.policies import MlpPolicy
from stable_baselines.common import make_vec_env
from stable_baselines import PPO2

# multiprocess environment
env = make_vec_env('CartPole-v1', n_envs=4)

model = PPO2(MlpPolicy, env, verbose=1)
model.learn(total_timesteps=25000)
model.save("ppo2_cartpole")

del model # remove to demonstrate saving and loading

model = PPO2.load("ppo2_cartpole")

# Enjoy trained agent
obs = env.reset()
while True:
    action, _states = model.predict(obs)
    obs, rewards, dones, info = env.step(action)
    env.render()

完整错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/var/folders/2l/c0wfhk2x0qz3v_6x0ylvvdr00000gn/T/ipykernel_4323/1825670659.py in <module>
      8 env = make_vec_env('CartPole-v1', n_envs=4)
      9 
---> 10 model = PPO2(MlpPolicy, env, verbose=1)
     11 model.learn(total_timesteps=25000)
     12 model.save("ppo2_cartpole")

~/miniconda3/envs/tf15/lib/python3.7/site-packages/stable_baselines/ppo2/ppo2.py in __init__(self, policy, env, gamma, n_steps, ent_coef, learning_rate, vf_coef, max_grad_norm, lam, nminibatches, noptepochs, cliprange, cliprange_vf, verbose, tensorboard_log, _init_setup_model, policy_kwargs, full_tensorboard_log, seed, n_cpu_tf_sess)
     95 
     96         if _init_setup_model:
---> 97             self.setup_model()
     98 
     99     def _make_runner(self):

~/miniconda3/envs/tf15/lib/python3.7/site-packages/stable_baselines/ppo2/ppo2.py in setup_model(self)
    108 
    109     def setup_model(self):
--> 110         with SetVerbosity(self.verbose):
    111 
    112             assert issubclass(self.policy, ActorCriticPolicy), "Error: the input policy for the PPO2 model must be " \

~/miniconda3/envs/tf15/lib/python3.7/site-packages/stable_baselines/common/base_class.py in __enter__(self)
   1127         self.tf_level = os.environ.get('TF_CPP_MIN_LOG_LEVEL', '0')
   1128         self.log_level = logger.get_level()
-> 1129         self.gym_level = gym.logger.MIN_LEVEL
   1130 
   1131         if self.verbose <= 1:

AttributeError: module 'gym.logger' has no attribute 'MIN_LEVEL'

原文链接:https://stackoverflow.com//questions/71449872/stable-baselines-module-error-gym-logger-has-no-attribute-min-level

回复

我来回复
  • Masoud的头像
    Masoud 评论

    您必须使用以下命令将您的健身房模块更新到最新版本:

    pip install gym[all] -U
    

    在你的命令行中

    1年前 0条评论