Gymnasium: [Question] Weird TypeError occurs when trying to import gymnasium

Question

I am trying to use the latest version of gymnasium with python 3.10.6 on Ubuntu 22.04. When I type import gymnasium, I get the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode
    exec(code, self.locals)
  File "<pyshell#0>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/gymnasium/__init__.py", line 12, in <module>
    from gymnasium.envs.registration import make, spec, register, registry, pprint_registry
  File "/usr/local/lib/python3.10/dist-packages/gymnasium/envs/__init__.py", line 364, in <module>
    load_env_plugins()
  File "/usr/local/lib/python3.10/dist-packages/gymnasium/envs/registration.py", line 273, in load_env_plugins
    for plugin in metadata.entry_points(group=entry_point):
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 1009, in entry_points
    return SelectableGroups.load(eps).select(**params)
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 459, in load
    ordered = sorted(eps, key=by_group)
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 1006, in <genexpr>
    eps = itertools.chain.from_iterable(
  File "/usr/lib/python3.10/importlib/metadata/_itertools.py", line 16, in unique_everseen
    k = key(element)
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 941, in _normalized_name
    return self._name_from_stem(stem) or super()._normalized_name
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 622, in _normalized_name
    return Prepared.normalize(self.name)
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 871, in normalize
    return re.sub(r"[-_.]+", "-", name).lower().replace('-', '_')
  File "/usr/lib/python3.10/re.py", line 209, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or bytes-like object

I would greatly appreciate guidance on how to fix it.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

Right now I think I might go the route of removing my python3.10 installation and rebuilding the ecosystem from scratch. Would that be a safe and viable approach? In particular, would it get rid of the files that are causing the problem?