semitable / lb-foraging

Level-based Foraging (LBF): A multi-agent environment for RL
MIT License
151 stars 64 forks source link

Failed to import lbforaging #14

Closed gsavarela closed 2 years ago

gsavarela commented 2 years ago

Hi,

I am trying to import lbforaging module both pip installed or git cloned without success. The import is never finished and the code has to be interrupted:

(aasma) $ python lbforaging.py
^CTraceback (most recent call last):
  File "lbforaging.py", line 7, in <module>
    import lbforaging
  File "/home/gsavarela/Repos/lb-foraging/lbforaging/__init__.py", line 23, in <module>
    "grid_observation": grid_obs,
  File "/home/gsavarela/.local/share/.pyenv/versions/aasma/lib/python3.7/site-packages/gym/envs/registration.py", line 613, in register
    return registry.register(id, **kwargs)
  File "/home/gsavarela/.local/share/.pyenv/versions/aasma/lib/python3.7/site-packages/gym/envs/registration.py", line 559, in register
    versions = self.env_specs.versions(spec.namespace, spec.name)
  File "/home/gsavarela/.local/share/.pyenv/versions/aasma/lib/python3.7/site-packages/gym/envs/registration.py", line 220, in versions
    self._assert_name_exists(namespace, name)
  File "/home/gsavarela/.local/share/.pyenv/versions/aasma/lib/python3.7/site-packages/gym/envs/registration.py", line 293, in _assert_name_exists
    suggestions = difflib.get_close_matches(name, self.names(namespace), n=1)
  File "/home/gsavarela/.local/share/.pyenv/versions/3.7.5/lib/python3.7/difflib.py", line 726, in get_close_matches
    if s.real_quick_ratio() >= cutoff and \
  File "/home/gsavarela/.local/share/.pyenv/versions/3.7.5/lib/python3.7/difflib.py", line 686, in real_quick_ratio
    return _calculate_ratio(min(la, lb), la + lb)

The offending line 220 seem to be a failed assertion. Upon closer inspection I got, namespace=None and name='CartPole':

ipdb> c 2020
> /home/gsavarela/.local/share/.pyenv/versions/aasma/lib/python3.7/site-packages/gym/envs/registration.py(221)versions()
    220         import ipdb; ipdb.set_trace()
--> 221         self._assert_name_exists(namespace, name)
    222

ipdb> namespace
ipdb> name
'CartPole'
ipdb>

My system is archlinux and my python version is 3.7.5

Could you point me to the right direction? Your project seems very promissing. Thanks in advance.

gsavarela commented 2 years ago

Hi for those interested, I was able to solve the issue by replacing gym-0.23.0 for gym-0.21.0, i.e;

pip install gym==0.21.0

So as side note you should provide a requirements.txt file or report it on the README.md the tested version for gym.

Regards,