使用 conda 在 WSL ubuntu 中安装 nes-py 时出现问题

Problem installing nes-py in WSL ubuntu using conda

我试图使用 pip install nes-py 在 WSL 中安装 nes-py,但出现以下错误(我正在粘贴整个终端消息)。

Collecting nes-py
  Using cached nes_py-8.1.8.tar.gz (76 kB)
Requirement already satisfied: gym>=0.17.2 in /home/aarav18/anaconda3/lib/python3.9/site-packages (from nes-py) (0.21.0)
Requirement already satisfied: numpy>=1.18.5 in /home/aarav18/anaconda3/lib/python3.9/site-packages (from nes-py) (1.20.3)
Requirement already satisfied: pyglet<=1.5.11,>=1.4.0 in /home/aarav18/anaconda3/lib/python3.9/site-packages (from nes-py) (1.5.11)
Requirement already satisfied: tqdm>=4.48.2 in /home/aarav18/anaconda3/lib/python3.9/site-packages (from nes-py) (4.62.3)
Requirement already satisfied: cloudpickle>=1.2.0 in /home/aarav18/anaconda3/lib/python3.9/site-packages (from gym>=0.17.2->nes-py) (2.0.0)
Building wheels for collected packages: nes-py
  Building wheel for nes-py (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/aarav18/anaconda3/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qez02o65/nes-py_a58dccafc96a4ee491ab6256d3849570/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qez02o65/nes-py_a58dccafc96a4ee491ab6256d3849570/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-84x8fqpu
       cwd: /tmp/pip-install-qez02o65/nes-py_a58dccafc96a4ee491ab6256d3849570/
  Complete output (27 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.9
  creating build/lib.linux-x86_64-3.9/nes_py
  copying nes_py/nes_env.py -> build/lib.linux-x86_64-3.9/nes_py
  copying nes_py/_image_viewer.py -> build/lib.linux-x86_64-3.9/nes_py
  copying nes_py/__init__.py -> build/lib.linux-x86_64-3.9/nes_py
  copying nes_py/_rom.py -> build/lib.linux-x86_64-3.9/nes_py
  creating build/lib.linux-x86_64-3.9/nes_py/app
  copying nes_py/app/play_random.py -> build/lib.linux-x86_64-3.9/nes_py/app
  copying nes_py/app/cli.py -> build/lib.linux-x86_64-3.9/nes_py/app
  copying nes_py/app/play_human.py -> build/lib.linux-x86_64-3.9/nes_py/app
  copying nes_py/app/__init__.py -> build/lib.linux-x86_64-3.9/nes_py/app
  creating build/lib.linux-x86_64-3.9/nes_py/wrappers
  copying nes_py/wrappers/joypad_space.py -> build/lib.linux-x86_64-3.9/nes_py/wrappers
  copying nes_py/wrappers/__init__.py -> build/lib.linux-x86_64-3.9/nes_py/wrappers
  running build_ext
  building 'nes_py.lib_nes_env' extension
  creating build/temp.linux-x86_64-3.9
  creating build/temp.linux-x86_64-3.9/nes_py
  creating build/temp.linux-x86_64-3.9/nes_py/nes
  creating build/temp.linux-x86_64-3.9/nes_py/nes/src
  creating build/temp.linux-x86_64-3.9/nes_py/nes/src/mappers
  g++ -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/aarav18/anaconda3/include -I/home/aarav18/anaconda3/include -fPIC -O2 -isystem /home/aarav18/anaconda3/include -fPIC -Ines_py/nes/include -I/home/aarav18/anaconda3/include/python3.9 -c nes_py/nes/src/cartridge.cpp -o build/temp.linux-x86_64-3.9/nes_py/nes/src/cartridge.o -std=c++1y -march=native -pipe -O3
  error: command 'g++' failed: No such file or directory
  ----------------------------------------
  ERROR: Failed building wheel for nes-py
  Running setup.py clean for nes-py
Failed to build nes-py
Installing collected packages: nes-py
    Running setup.py install for nes-py ... error
    ERROR: Command errored out with exit status 1:
     command: /home/aarav18/anaconda3/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qez02o65/nes-py_a58dccafc96a4ee491ab6256d3849570/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qez02o65/nes-py_a58dccafc96a4ee491ab6256d3849570/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-kqt46_5n/install-record.txt --single-version-externally-managed --compile --install-headers /home/aarav18/anaconda3/include/python3.9/nes-py
         cwd: /tmp/pip-install-qez02o65/nes-py_a58dccafc96a4ee491ab6256d3849570/
    Complete output (27 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.9
    creating build/lib.linux-x86_64-3.9/nes_py
    copying nes_py/nes_env.py -> build/lib.linux-x86_64-3.9/nes_py
    copying nes_py/_image_viewer.py -> build/lib.linux-x86_64-3.9/nes_py
    copying nes_py/__init__.py -> build/lib.linux-x86_64-3.9/nes_py
    copying nes_py/_rom.py -> build/lib.linux-x86_64-3.9/nes_py
    creating build/lib.linux-x86_64-3.9/nes_py/app
    copying nes_py/app/play_random.py -> build/lib.linux-x86_64-3.9/nes_py/app
    copying nes_py/app/cli.py -> build/lib.linux-x86_64-3.9/nes_py/app
    copying nes_py/app/play_human.py -> build/lib.linux-x86_64-3.9/nes_py/app
    copying nes_py/app/__init__.py -> build/lib.linux-x86_64-3.9/nes_py/app
    creating build/lib.linux-x86_64-3.9/nes_py/wrappers
    copying nes_py/wrappers/joypad_space.py -> build/lib.linux-x86_64-3.9/nes_py/wrappers
    copying nes_py/wrappers/__init__.py -> build/lib.linux-x86_64-3.9/nes_py/wrappers
    running build_ext
    building 'nes_py.lib_nes_env' extension
    creating build/temp.linux-x86_64-3.9
    creating build/temp.linux-x86_64-3.9/nes_py
    creating build/temp.linux-x86_64-3.9/nes_py/nes
    creating build/temp.linux-x86_64-3.9/nes_py/nes/src
    creating build/temp.linux-x86_64-3.9/nes_py/nes/src/mappers
    g++ -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/aarav18/anaconda3/include -I/home/aarav18/anaconda3/include -fPIC -O2 -isystem /home/aarav18/anaconda3/include -fPIC -Ines_py/nes/include -I/home/aarav18/anaconda3/include/python3.9 -c nes_py/nes/src/cartridge.cpp -o build/temp.linux-x86_64-3.9/nes_py/nes/src/cartridge.o -std=c++1y -march=native -pipe -O3
    error: command 'g++' failed: No such file or directory
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/aarav18/anaconda3/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qez02o65/nes-py_a58dccafc96a4ee491ab6256d3849570/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qez02o65/nes-py_a58dccafc96a4ee491ab6256d3849570/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-kqt46_5n/install-record.txt --single-version-externally-managed --compile --install-headers /home/aarav18/anaconda3/include/python3.9/nes-py Check the logs for full command output.

我尝试了很多修复,例如克隆 nes-py 仓库并通过 运行 python setup.py install 安装它到它的目录,更改 MANIFEST.in 文件,以及其他一些,但没有任何效果。如果有人能以任何方式提供帮助,那就太好了!

提前致谢!

P.S。我不熟悉同时使用 Conda 和 WSL/Ubuntu,因此也非常感谢这方面的任何帮助。我以前只是使用与 VS Code 集成的 cmd。

找到解决方案。花了一段时间,但这是一个简单的。我只需要在终端中通过 运行 sudo apt install g++ 安装 g++。在那之后,nes-py 的安装就像一个魅力。