pythonpipwindows-subsystem-for-linuxopenai-gympython-3.12

Error while running "pip install gym==0.21.0" in WSL 2: "AttributeError: module 'pkgutil' has no attribute 'ImpImporter'"


I ran "pip install gym==0.21.0" then got this

Collecting gym==0.21.0
  Using cached gym-0.21.0.tar.gz (1.5 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 14, in <module>
        File "/root/anaconda3/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
          import setuptools.version
        File "/root/anaconda3/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
          import pkg_resources
        File "/root/anaconda3/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2191, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

Can someone help me?

I tried running pip install setuptools==65.5.0 "wheel<0.40.0" then restarting my WSL but it didn't work.


Solution

  • gym 0.21.0 only has support for Python 3.6 - 3.9. You may have to downgrade to a supported Python version and try again.