# AttributeError: 'SingleAgentEnvRunner' object has no attribute 'get\_policy'

**URL:** <https://discuss.ray.io/t/attributeerror-singleagentenvrunner-object-has-no-attribute-get-policy/22317>\
**Category:** Uncategorized\
**Created:** [April 15, 2025, 1:42pm UTC](https://discuss.ray.io/t/attributeerror-singleagentenvrunner-object-has-no-attribute-get-policy/22317 "2025-04-15T13:42:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hasnain\_Fareed](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/hasnain_fareed/32/5225_2.png) [@Hasnain\_Fareed](https://discuss.ray.io/u/Hasnain_Fareed)\
**Post date:** [April 15, 2025, 1:42pm UTC](https://discuss.ray.io/t/attributeerror-singleagentenvrunner-object-has-no-attribute-get-policy/22317/1 "2025-04-15T13:42:28Z")

</div>

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() ’

---

<div class="post-metadata">

**Author:** ![armmer016](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/armmer016/32/8080_2.png) [@armmer016](https://discuss.ray.io/u/armmer016)\
**Post date:** [July 6, 2025, 1:13pm UTC](https://discuss.ray.io/t/attributeerror-singleagentenvrunner-object-has-no-attribute-get-policy/22317/2 "2025-07-06T13:13:43Z")

</div>

I got same problem here. Any updates on this?

---

<div class="post-metadata">

**Author:** ![Hasnain\_Fareed](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/hasnain_fareed/32/5225_2.png) [@Hasnain\_Fareed](https://discuss.ray.io/u/Hasnain_Fareed)\
**Post date:** [July 6, 2025, 2:00pm UTC](https://discuss.ray.io/t/attributeerror-singleagentenvrunner-object-has-no-attribute-get-policy/22317/3 "2025-07-06T14:00:10Z")

</div>

Hey, which model are you running, I got the solution for this.

---

<div class="post-metadata">

**Author:** ![armmer016](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/armmer016/32/8080_2.png) [@armmer016](https://discuss.ray.io/u/armmer016)\
**Post date:** [July 6, 2025, 2:20pm UTC](https://discuss.ray.io/t/attributeerror-singleagentenvrunner-object-has-no-attribute-get-policy/22317/4 "2025-07-06T14:20:42Z")

</div>

I’m running on DQN algorithm, Could you please share the solution for this error?

---

<div class="post-metadata">

**Author:** ![Ana\_Silvia\_C\_Silva](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/ana_silvia_c_silva/32/7716_2.png) [@Ana\_Silvia\_C\_Silva](https://discuss.ray.io/u/Ana_Silvia_C_Silva)\
**Post date:** [October 1, 2025, 2:34pm UTC](https://discuss.ray.io/t/attributeerror-singleagentenvrunner-object-has-no-attribute-get-policy/22317/5 "2025-10-01T14:34:48Z")

</div>

same issue also with DQN, any help appreciated.

edit: replacing `.get_policy().model` with `get_module()` worked for my purposes. seems to be another issue with out of date documentation and examples…

---

<div class="post-metadata">

**Author:** ![christina](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/christina/32/7542_2.png) [@christina](https://discuss.ray.io/u/christina)\
**Post date:** [October 1, 2025, 6:37pm UTC](https://discuss.ray.io/t/attributeerror-singleagentenvrunner-object-has-no-attribute-get-policy/22317/6 "2025-10-01T18:37:47Z")

</div>

Thanks for flagging this! I’ll try to get this updated in the docs / examples 🙂

---

<div class="post-metadata">

**Author:** ![Ana\_Silvia\_C\_Silva](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/ana_silvia_c_silva/32/7716_2.png) [@Ana\_Silvia\_C\_Silva](https://discuss.ray.io/u/Ana_Silvia_C_Silva)\
**Post date:** [October 2, 2025, 7:40am UTC](https://discuss.ray.io/t/attributeerror-singleagentenvrunner-object-has-no-attribute-get-policy/22317/7 "2025-10-02T07:40:44Z")

</div>

Thanks! But while that solution worked for extracting the model architecture, it does not help when I want to actually get the learned policy and test it. I’m looking through the codebase and can’t quite figure it out; it seems like [this line](https://github.com/ray-project/ray/blob/master/rllib/algorithms/algorithm.py#L2419) fails because `type(self.env_runner)` is `<class 'ray.rllib.env.single_agent_env_runner.SingleAgentEnvRunner'>`, which afaict does not define `get_policy` and neither do its parent classes.
