Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'FlattenObservation' #1058

Open
SHYang1210 opened this issue Dec 16, 2019 · 7 comments
Open

ImportError: cannot import name 'FlattenObservation' #1058

SHYang1210 opened this issue Dec 16, 2019 · 7 comments

Comments

@SHYang1210
Copy link

After I installed it according to the requirements, I got an ImportError: cannot import name 'FlattenObservation' error. I know that it is the version of the gym package or something went wrong elsewhere. Thanks for the help!
File "/home/xxx/baselines/baselines/run.py", line 12, in
from baselines.common.cmd_util import common_arg_parser, parse_unknown_args, make_vec_env, make_env
File "/home/xxx/baselines/baselines/common/cmd_util.py", line 12, in
from gym.wrappers import FlattenObservation, FilterObservation
ImportError: cannot import name 'FlattenObservation'

@MatPoliquin
Copy link
Contributor

pip3 show gym
What version do you see?

I got the same error, you can fix it by installing 0.15.4:
pip3 install gym==0.15.4

@yemam3
Copy link

yemam3 commented Jan 9, 2020

I'm getting the same issue and my gym version is 0.15.4... any other recommended fixes?

@ryanmaxwell96
Copy link

I am also getting the same issue with 0.15.4. Any help?

@ryanmaxwell96
Copy link

So I'm not sure if this is the answer, but upon looking into the gym/gym/wrappers, folder, it looks like there are only files named "flatten_ovservation" and "filter_observation" so I just chose to import the entire wrappers folder with:

from gym import wrappers

in the cmd_util.py file to get beyond this error. Of course now I get a new error though:
File "baselines/common/retro_wrappers.py", line 202
def make_retro(*, game, state=None, max_episode_steps=4500, **kwargs):
^
SyntaxError: invalid syntax

@SHYang1210
Copy link
Author

9ee399f
Check your gym version first, the package is modified after 0.15.4, you can check the link above, you can reduce your gym version, use the previous package

@ryanmaxwell96
Copy link

So what if we have 0.15.4 already? go even earlier?

@ryanmaxwell96
Copy link

I was finally able to get it to work, though with gym 0.15.3 not 0.15.4. Also, I had to remove two underscores in the run.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants