# Exercise 2.3: ImportError: 'module' object has no attribute 'CartPoleStayUpEnv'

**URL:** <https://get-help.theconstruct.ai/t/exercise-2-3-importerror-module-object-has-no-attribute-cartpolestayupenv/2634>\
**Category:** Using OpenAI With ROS\
**Created:** [March 20, 2020, 9:16pm UTC](https://get-help.theconstruct.ai/t/exercise-2-3-importerror-module-object-has-no-attribute-cartpolestayupenv/2634 "2020-03-20T21:16:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![linsu.han](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/linsu.han/32/10_2.png) [@linsu.han](https://get-help.theconstruct.ai/u/linsu.han)\
**Post date:** [March 20, 2020, 9:16pm UTC](https://get-help.theconstruct.ai/t/exercise-2-3-importerror-module-object-has-no-attribute-cartpolestayupenv/2634/1 "2020-03-20T21:16:41Z")

</div>

After following the instructions step-by-step and running:

```auto
roslaunch my_cartpole_training start_training.launch

```

, I am receiving this error:

```auto
ROS_MASTER_URI=http://master:11311

process[cartpole_gym-1]: started with pid [17866]
/usr/local/lib/python2.7/dist-packages/requests/ __init__.py:91: RequestsDependencyWarning: urllib3 (1.25.8) or chardet (2.3.0) doesn't match a supported version!
  RequestsDependencyWarning)
/usr/local/lib/python2.7/dist-packages/requests/ __init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Traceback (most recent call last):
  File "/home/user/my_cartpole_training/src/start_qlearn.py", line 24, in <module>
    env = gym.make('CartPoleStayUp-v1')
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 161, in make
    return registry.make(id)
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 119, in make
    env = spec.make()
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 85, in make
    cls = load(self._entry_point)
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 17, in load
    result = entry_point.load(False)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/ __init__.py", line 2229, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/ __init__.py", line 2239, in resolve
    raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'CartPoleStayUpEnv'
[cartpole_gym-1] process has died [pid 17866, exit code 1, cmd /home/user/my_cartpole_training/src/start_qlearn.py __name:=cartpole_gym__ log:=/home/user/.ros/log/58da97f2-6adc-11ea-8bb0-16ab3dc29d7b/cartpole_gym-1.log].
log file: /home/user/.ros/log/58da97f2-6adc-11ea-8bb0-16ab3dc29d7b/cartpole_gym-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done

```

---

<div class="post-metadata">

**Author:** ![simon.steinmann91](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/simon.steinmann91/32/324_2.png) [@simon.steinmann91](https://get-help.theconstruct.ai/u/simon.steinmann91)\
**Post date:** [March 22, 2020, 12:01pm UTC](https://get-help.theconstruct.ai/t/exercise-2-3-importerror-module-object-has-no-attribute-cartpolestayupenv/2634/2 "2020-03-22T12:01:10Z")

</div>

> [@linsu.han](#):
>
> CartPoleStayUpEnv

Is this class present in the file, where your

```auto
'CartPoleStayUp-v1'

```

gym environment is defined?

---

<div class="post-metadata">

**Author:** ![linsu.han](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/linsu.han/32/10_2.png) [@linsu.han](https://get-help.theconstruct.ai/u/linsu.han)\
**Post date:** [March 23, 2020, 4:35pm UTC](https://get-help.theconstruct.ai/t/exercise-2-3-importerror-module-object-has-no-attribute-cartpolestayupenv/2634/3 "2020-03-23T16:35:28Z")

</div>

Yep here are the steps I took:

1. Copied `stay_up.py` to `src/my_cartpole_task_env.py`
2. `vim my_cartpole_task_env.py`
3. `:%s/v0/v1/g` `:wq` # replaced all occurrences of “v0” to “v1”
4. `vim start_training.py`
5. Changed `from openai_ros.task_envs.cartpole_stay_up import stay_up` to `from my_cartpole_task_env import stay_up`
6. Also tried `from openai_ros.task_envs.cartpole_stay_up import stay_up` to `import my_cartpole_task_env`
7. `:%s/v0/v1/g` `:wq`
8. `roslaunch my_cartpole_training start_training.launch`

---

<div class="post-metadata">

**Author:** ![simon.steinmann91](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/simon.steinmann91/32/324_2.png) [@simon.steinmann91](https://get-help.theconstruct.ai/u/simon.steinmann91)\
**Post date:** [March 24, 2020, 4:15pm UTC](https://get-help.theconstruct.ai/t/exercise-2-3-importerror-module-object-has-no-attribute-cartpolestayupenv/2634/4 "2020-03-24T16:15:46Z")

</div>

Does your file ‘my\_cartpole\_task\_env’ have the correct entry point? This should be what causes the error.

---

<div class="post-metadata">

**Author:** ![ilyas95](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/ilyas95/32/10_2.png) [@ilyas95](https://get-help.theconstruct.ai/u/ilyas95)\
**Post date:** [April 5, 2020, 11:04am UTC](https://get-help.theconstruct.ai/t/exercise-2-3-importerror-module-object-has-no-attribute-cartpolestayupenv/2634/5 "2020-04-05T11:04:15Z")

</div>

I had the same problem and I solved by changing the entry point from ‘openai\_ros:CartPoleStayUpEnv’ to ‘my\_cartpole\_task\_env:CartPoleStayUpEnv’

---

<div class="post-metadata">

**Author:** ![linsu.han](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/linsu.han/32/10_2.png) [@linsu.han](https://get-help.theconstruct.ai/u/linsu.han)\
**Post date:** [April 10, 2020, 3:13pm UTC](https://get-help.theconstruct.ai/t/exercise-2-3-importerror-module-object-has-no-attribute-cartpolestayupenv/2634/6 "2020-04-10T15:13:02Z")

</div>

Thanks that solved the issue.
