这是indexloc提供的服务,不要输入任何密码
Skip to content

Getting started example causes TypeError: object of type 'TimeLimit' has no len() #819

@SorenSc

Description

@SorenSc
  • I have marked all applicable categories:
    • exception-raising bug
    • RL algorithm bug
    • documentation request (i.e. "X is missing from the documentation.")
    • new feature request
  • I have visited the source website
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and environment, where applicable:
    import tianshou, gym, torch, numpy, sys
    print(tianshou.__version__, gym.__version__, torch.__version__, numpy.__version__, sys.version, sys.platform)
    # 0.4.11 0.26.2 1.13.1 1.23.5 3.10.9 (main, Mar  1 2023, 12:20:14) [Clang 14.0.6 ] darwin
    # I'm using gymnasium (import gymnasium as gym)
    # I'm running it on an Apple M1 Pro

I'm tryin to execute the example on the start page (https://github.com/thu-ml/tianshou).

When running

collector = ts.data.Collector(policy, env, exploration_noise=True)

I ran into the following

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[8], line 3
      1 policy.eval()
      2 policy.set_eps(eps_test)
----> 3 collector = ts.data.Collector(policy, env, exploration_noise=True)
      4 collector.collect(n_episode=1, render=1 / 35)  

File ~/miniconda3/envs/rl-index/lib/python3.10/site-packages/tianshou/data/collector.py:72, in Collector.__init__(self, policy, env, buffer, preprocess_fn, exploration_noise)
     70 else:
     71     self.env = env  # type: ignore
---> 72 self.env_num = len(self.env)
     73 self.exploration_noise = exploration_noise
     74 self._assign_buffer(buffer)  

TypeError: object of type 'TimeLimit' has no len()

When doing the same in GoogleColab, I'm having the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnot reproduced yetNot yet tested or reproduced by a reviewer

    Type

    No type

    Projects

    Status

    To do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions