openai / gym

A toolkit for developing and comparing reinforcement learning algorithms.
https://www.gymlibrary.dev
Other
34.68k stars 8.61k forks source link

[Bug Report] Building wheel for gym (setup.py) ... error #3202

Open wbc23 opened 1 year ago

wbc23 commented 1 year ago

Describe the bug Building wheel for gym (setup.py) ... error

System Info My python version is 3.7.3,My linux version is Ubuntu18.04

The bug info is: Building wheels for collected packages: gym Building wheel for gym (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [481 lines of output]

Traceback (most recent call last): File "", line 36, in File "", line 34, in File "/tmp/pip-install-ghwoed05/gym_e92a96bf7ac54dd59edd31213e4aa557/setup.py", line 74, in "Programming Language :: Python :: 3.9", File "/usr/local/python3.7/lib/python3.7/site-packages/setuptools/init.py", line 87, in setup return distutils.core.setup(**attrs) File "/usr/local/python3.7/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) File "/usr/local/python3.7/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/usr/local/python3.7/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands self.run_command(cmd) File "/usr/local/python3.7/lib/python3.7/site-packages/setuptools/dist.py", line 1217, in run_command super().run_command(command) File "/usr/local/python3.7/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 987, in run_command cmd_obj.run() File "/usr/local/python3.7/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 395, in run self.egg2dist(self.egginfo_dir, distinfo_dir) File "/usr/local/python3.7/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 534, in egg2dist pkg_info = pkginfo_to_metadata(egginfo_path, pkginfo_path) File "/usr/local/python3.7/lib/python3.7/site-packages/wheel/metadata.py", line 160, in pkginfo_to_metadata for key, value in generate_requirements({extra: reqs}): File "/usr/local/python3.7/lib/python3.7/site-packages/wheel/metadata.py", line 138, in generate_requirements for new_req in convert_requirements(depends): File "/usr/local/python3.7/lib/python3.7/site-packages/wheel/metadata.py", line 103, in convert_requirements parsed_requirement = Requirement(req) File "/usr/local/python3.7/lib/python3.7/site-packages/wheel/vendored/packaging/requirements.py", line 37, in init raise InvalidRequirement(str(e)) from e wheel.vendored.packaging.requirements.InvalidRequirement: Expected end or semicolon (after version specifier) opencv-python>=3.


      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for gym
  Running setup.py clean for gym
Failed to build gym
pseudo-rnd-thoughts commented 1 year ago

pip install setuptools == 66 or modify the setup.py file to fix the issue

heiheiheibj commented 1 year ago

I'm getting the same error, it's not a setuptools version problem, it's a configuration error. Look carefully, opencv-python>=3. There is no number after 3. just change it to 3.0 or 3

HelloCentaurus commented 1 year ago

I'm getting the same error, it's not a setuptools version problem, it's a configuration error. Look carefully, opencv-python>=3. There is no number after 3. just change it to 3.0 or 3

Where can I find this file and modify it?

heiheiheibj commented 1 year ago

I couldn't find the location of the configuration file, so i used a very inelegant way to modify the code and solved this problem. [doge] Modify /usr/local/python3.7/lib/python3.7/site-packages/wheel/vendored/packaging/requirements.py

` def init(self, requirement_string: str) -> None:

    try:

        if requirement_string.find('opencv-python>=3.')>=0:

            requirement_string += "0"    # opencv-python>=3.0

        parsed = parse_requirement(requirement_string)

`

HelloCentaurus commented 1 year ago

I couldn't find the location of the configuration file, so I did a very dumb solution. Modify /usr/local/python3.7/lib/python3.7/site-packages/wheel/vendored/packaging/requirements.py

` def init(self, requirement_string: str) -> None:

    try:

        if requirement_string.find('opencv-python>=3.')>=0:

            requirement_string += "0"    # opencv-python>=3.0

        parsed = parse_requirement(requirement_string)

`

Anyway, this method helped me solve the problem. Thank you very much!

JakobThumm commented 1 year ago

Alternatively,

pip install git+https://github.com/openai/gym.git@9180d12e1b66e7e2a1a622614f787a6ec147ac40

installs gym==0.21 with the typo opencv-python>=3. fixed.

saulfield commented 1 year ago

This appears to be because of a change with wheel. Using wheel==0.38.4 worked for me.

pseudo-rnd-thoughts commented 1 year ago

In my case I just had to replace the gym== version being installed to gym, and the most recent version works, I guess.

Be aware that there are major api changes with the latest version compared to v0.21

RichardGe commented 1 month ago

FYI, on Windows, the file to modify manually is: C:\Users \ 'username'\AppData\Local\Programs\Python\Python'version'\Lib\site-packages\gym-0.21.0-py3.11.egg-info\requires.txt

destroy314 commented 1 month ago

pip install "pip<24.1" works for me