AttributeError: 'SingleAgentEnvRunner' object has no attribute 'get_policy'

I am gettng this error, its been on me from two days, and I am not able to make progress, somebody, kindly help me ‘AttributeError: ‘SingleAgentEnvRunner’ object has no attribute ‘get_policy’’

this is the whole code ’

Loading Checkpoint and running the gym environment

from ray import rllib
import gymnasium
from ray.rllib.algorithms.ppo import PPOConfig

env_name = “LunarLander-v3”
env = gymnasium.make(env_name,render_mode=“human”)
#algo = PPOConfig().environment(env_name).build()
checkpoint_path = “The Path”
my_ppo = (PPOConfig().environment(env_name)).build()
algo = my_ppo.from_checkpoint(checkpoint_path)

episode_reward = 0
terminated = truncated = False

if gymnasium:
obs, info = env.reset()
else:
obs = env.reset()

#while not terminated and not truncated:
for _ in range(500):

action = algo.compute_single_action(obs)

if gymnasium:
    obs, reward, terminated, truncated, info = env.step(action)
else:
    obs, reward, terminated, info = env.step(action)
episode_reward += reward

env.close() ’

1 Like