Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (30 sloc) 1.06 KB
layout title aside tags category author published key
article
cannot import name 'BinarySpaceToDiscreteSpaceEnv' Solve
toc
true
Programming
Programming
melonicedlatte
true
2019-06-09-202000

Problem

When you program using gym-super-mario-bros, you can see this error.

Traceback (most recent call last):
  File "1_sb_ppo_agent.py", line 10, in <module>
    from nes_py.wrappers import BinarySpaceToDiscreteSpaceEnv
ImportError: cannot import name 'BinarySpaceToDiscreteSpaceEnv' from 'nes_py.wrappers' (C:\Users\Anaconda3\lib\site-packages\nes_py\wrappers\__init__.py)

Solve

Maybe, because of version changed, You have to use JoypadSpace, not BinarySpaceToDiscreteSpaceEnv. https://github.com/Kautenja/nes-py/wiki/Wrappers. There is a solution. You have to change from BinarySpaceToDiscreteSpaceEnv to JoypadSpace. Like below example.

from nes_py.wrappers import JoypadSpace
env = JoypadSpace(env, [
    ['NOP'],
    ['right', 'A'],
    ['left', 'A'],
    ['A'],
])
You can’t perform that action at this time.