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

Import env errors #550

Closed
mvadrev opened this issue Nov 25, 2021 · 13 comments
Closed

Import env errors #550

mvadrev opened this issue Nov 25, 2021 · 13 comments
Labels
bug Something isn't working

Comments

@mvadrev
Copy link

mvadrev commented Nov 25, 2021

Hello,

I am new to MARL and want to create custom parallel env in PettingZoo and wanted to play with it. I am getting the following import error when attempting to get the environments.

from pettingzoo.butterfly import pistonball_v4 env = pistonball_v4.env()

`
ImportError: cannot import name 'pistonball_v4' from 'pettingzoo.butterfly'
PS C:\Users\mvadr\Desktop\gym>

`

@benblack769
Copy link
Contributor

For me, the code:

from pettingzoo.butterfly import pistonball_v4 
env = pistonball_v4.env()

Work just fine on pettingzoo==1.13.1. Could you say which version of pettingzoo you are running?

@mvadrev
Copy link
Author

mvadrev commented Nov 26, 2021

Hi Thanks for your reply. I am using Colab and installed 1.13.1 with pip but getting the following error.

image

@benblack769
Copy link
Contributor

I was able to reproduce the problem in colab.

A weird, but effective workaround is to do this:

import pettingzoo.butterfly.pistonball_v4 as pistonball_v4
pistonball_v4.env()

I have no idea why this works and not the earlier statement. Very mysterious. Maybe colab has some special python version they deploy?

@mvadrev
Copy link
Author

mvadrev commented Nov 26, 2021

It is strange indeed but I can confirm I get the same error on my local machine too. Thanks for the fix though!

@benblack769
Copy link
Contributor

Out of curiosity, which python version are you running? I haven't tested it with python 3.9 or 3.10 yet.

@mvadrev
Copy link
Author

mvadrev commented Nov 27, 2021

Hey Ben. its 3.9.9

@benblack769
Copy link
Contributor

Thanks. I'll try to install a python3.9 environment and try to fix this soon.

@nikhilweee
Copy link
Contributor

Can confirm the same. I'm running the 13lines tutorial with pettingzoo 1.12, python 3.8.12, and conda 4.11 on Apple M1.

$ python 13lines.py
Traceback (most recent call last):
  File "13lines.py", line 3, in <module>
    from pettingzoo.butterfly import pistonball_v4
  File "/opt/homebrew/Caskroom/mambaforge/base/envs/rl/lib/python3.8/site-packages/pettingzoo/butterfly/__init__.py", line 5, in __getattr__
    return depricated_handler(env_name, __path__, __name__)
  File "/opt/homebrew/Caskroom/mambaforge/base/envs/rl/lib/python3.8/site-packages/pettingzoo/utils/deprecated_module.py", line 42, in depricated_handler
    raise ImportError(f"cannot import name '{env_name}' from '{module_name}'")
ImportError: cannot import name 'pistonball_v4' from 'pettingzoo.butterfly'

@benblack769
Copy link
Contributor

@nikhilweee If you are using pettingzoo 1.12, this might be expecected behavior---if I'm not mistaken, then that version of pettingzoo contains pistonball_v3, not pistonball_v4.

Try to see if the fix above import pettingzoo.butterfly.pistonball_v4 as pistonball_v4 fixes your issue, and if not if impporting

from pettingzoo.butterfly import pistonball_v3 fixes your issue

@benblack769 benblack769 added the bug Something isn't working label Nov 28, 2021
@jkterry1
Copy link
Member

@benblack769 I just got this bug installing the newest version of pettingzoo on pypi in a virtualenv on GCP too. This is real

@jkterry1
Copy link
Member

jkterry1 commented Nov 30, 2021

using pz 1.13.1 and python 3.7.9

@capyun
Copy link

capyun commented Dec 15, 2021

hello, i am using python3.8, pettingzoo 1.14.0,
and i get some error:

env = pistonball_v4.parallel_env(n_pistons=20, time_penalty=-0.1,
this raise DeprecatedEnv(f"{name}_v{old_version} is now deprecated, use {name}_v{new_version} instead")
pettingzoo.utils.deprecated_module.DeprecatedEnv: pistonball_v4 is now deprecated, use pistonball_v5 instead

when i use v5
from pettingzoo.butterfly import pistonball_v5
this raise ImportError(f"cannot import name '{env_name}' from '{module_name}'")
ImportError: cannot import name 'pistonball_v5' from 'pettingzoo.butterfly'

@jkterry1
Copy link
Member

So, for all future travelers, this issue comes up when upgrading Pettingzoo, for reasons we aren't able to figure out. IF you just uninstall/reinstall, the problem goes away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants