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

[BUG]TypeError: __init__() got an unexpected keyword argument 'disable_env_checker' #689

Closed
neuronphysics opened this issue Nov 21, 2022 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@neuronphysics
Copy link

I used your library on google colab and it works without a problem. However, after spending a day to install gym in ubuntu using conda and run torchrl code, I am getting this error:

>>> from torchrl.envs.libs.gym import _has_gym, GymEnv, GymWrapper
>>> env_torchrl = GymEnv("InvertedPendulum-v2")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/anaconda3/lib/python3.9/site-packages/torchrl/envs/libs/gym.py", line 282, in __init__
    super().__init__(**kwargs)
  File "/home/anaconda3/lib/python3.9/site-packages/torchrl/envs/libs/gym.py", line 149, in __init__
    super().__init__(**kwargs)
  File "/home/anaconda3/lib/python3.9/site-packages/torchrl/envs/common.py", line 717, in __init__
    self._env = self._build_env(**kwargs)  # writes the self._env attribute
  File "/home/anaconda3/lib/python3.9/site-packages/torchrl/envs/libs/gym.py", line 327, in _build_env
    raise err
  File "/home/anaconda3/lib/python3.9/site-packages/torchrl/envs/libs/gym.py", line 313, in _build_env
    env = self.lib.make(env_name, **kwargs)
  File "/home/anaconda3/lib/python3.9/site-packages/gym/envs/registration.py", line 235, in make
    return registry.make(id, **kwargs)
  File "/home/anaconda3/lib/python3.9/site-packages/gym/envs/registration.py", line 129, in make
    env = spec.make(**kwargs)
  File "/home/anaconda3/lib/python3.9/site-packages/gym/envs/registration.py", line 90, in make
    env = cls(**_kwargs)
TypeError: __init__() got an unexpected keyword argument 'disable_env_checker'

Why did this error occur?

@neuronphysics neuronphysics added the bug Something isn't working label Nov 21, 2022
@vmoens
Copy link
Contributor

vmoens commented Nov 21, 2022

Hi @neuronphysics thanks for reporting this.
May I ask which version of gym you're using?

@neuronphysics
Copy link
Author

@vmoens Thanks for the reply. The gym version that I have is gym.__version__ '0.21.0'

@vmoens
Copy link
Contributor

vmoens commented Nov 21, 2022

The latest version of the code should not have this problem, let me update the wheels on PyPI :)

@vmoens
Copy link
Contributor

vmoens commented Nov 21, 2022

The new wheels should solve this issue. Let me know if it doesn't, happy to re-open then.

@vmoens vmoens closed this as completed Nov 21, 2022
@neuronphysics
Copy link
Author

Hello,
I was able to install torchrl in the jupyter notebook locally and run it. However, when I tried to re-run my previous code in google colab I am getting the following error:

     54 get_ipython().system('pip3 install torchrl')
---> 55 import torchrl
     56 #https://github.com/pytorch/rl
     57 from torchrl.envs.libs.gym import _has_gym, GymEnv, GymWrapper

7 frames
[/usr/local/lib/python3.7/dist-packages/torchrl/__init__.py](https://localhost:8080/#) in <module>
     33 
     34 
---> 35 import torchrl.collectors
     36 import torchrl.data
     37 import torchrl.envs

[/usr/local/lib/python3.7/dist-packages/torchrl/collectors/__init__.py](https://localhost:8080/#) in <module>
      4 # LICENSE file in the root directory of this source tree.
      5 
----> 6 from .collectors import (
      7     SyncDataCollector,
      8     aSyncDataCollector,

[/usr/local/lib/python3.7/dist-packages/torchrl/collectors/collectors.py](https://localhost:8080/#) in <module>
     22 from torch.utils.data import IterableDataset
     23 
---> 24 from torchrl.envs.transforms import TransformedEnv
     25 from torchrl.envs.utils import set_exploration_mode, step_mdp
     26 from .._utils import _check_for_faulty_process, prod

[/usr/local/lib/python3.7/dist-packages/torchrl/envs/__init__.py](https://localhost:8080/#) in <module>
      4 # LICENSE file in the root directory of this source tree.
      5 
----> 6 from .common import Specs, make_tensordict, EnvBase, EnvMetaData
      7 from .env_creator import EnvCreator, get_env_metadata
      8 from .gym_like import GymLikeEnv, default_info_dict_reader

[/usr/local/lib/python3.7/dist-packages/torchrl/envs/common.py](https://localhost:8080/#) in <module>
     16 from tensordict.tensordict import TensorDictBase, TensorDict
     17 
---> 18 from torchrl.data import CompositeSpec, TensorSpec
     19 from .._utils import seed_generator, prod
     20 from ..data.utils import DEVICE_TYPING

[/usr/local/lib/python3.7/dist-packages/torchrl/data/__init__.py](https://localhost:8080/#) in <module>
      5 
      6 from .postprocs import MultiStep
----> 7 from .replay_buffers import (
      8     ReplayBuffer,
      9     PrioritizedReplayBuffer,

[/usr/local/lib/python3.7/dist-packages/torchrl/data/replay_buffers/__init__.py](https://localhost:8080/#) in <module>
      4 # LICENSE file in the root directory of this source tree.
      5 
----> 6 from .replay_buffers import (
      7     ReplayBuffer,
      8     PrioritizedReplayBuffer,

[/usr/local/lib/python3.7/dist-packages/torchrl/data/replay_buffers/replay_buffers.py](https://localhost:8080/#) in <module>
     18 from torch import Tensor
     19 
---> 20 from torchrl._torchrl import (
     21     MinSegmentTreeFp32,
     22     MinSegmentTreeFp64,

ImportError: /usr/local/lib/python3.7/dist-packages/torchrl/_torchrl.so: undefined symbol: _ZN8pybind116detail11type_casterIN2at6TensorEvE4loadENS_6handleEb

Any idea why I am getting this new error?

@vmoens
Copy link
Contributor

vmoens commented Nov 22, 2022

Unfortunately this is a known issue (#619), our cp37 wheels do not work across all python 3.7 binaries.
In the meantime, you can execute

!pip install "git+https://github.com/pytorch/[email protected]"

@neuronphysics
Copy link
Author

Thank you @vmoens for the reply. t I still get this error after using the line you suggested above for installing torchrl:

Successfully built torchrl
Installing collected packages: tensordict, torchrl
Successfully installed tensordict-0.0.1a0 torchrl-0.0.3+88f9b26
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
[<ipython-input-4-0a405d54cda0>](https://localhost:8080/#) in <module>
     48 import math
     49 get_ipython().system('pip install "git+https://github.com/pytorch/[email protected]"')
---> 50 import torchrl
     51 #https://github.com/pytorch/rl
     52 from torchrl.envs.libs.gym import _has_gym, GymEnv, GymWrapper

7 frames
[/usr/local/lib/python3.7/dist-packages/torchrl/data/replay_buffers/replay_buffers.py](https://localhost:8080/#) in <module>
     18 from torch import Tensor
     19 
---> 20 from torchrl._torchrl import (
     21     MinSegmentTreeFp32,
     22     MinSegmentTreeFp64,

ImportError: /usr/local/lib/python3.7/dist-packages/torchrl/_torchrl.so: undefined symbol: _ZN8pybind116detail11type_casterIN2at6TensorEvE4loadENS_6handleEb

Any other suggestions?

@vmoens
Copy link
Contributor

vmoens commented Nov 22, 2022

Are you sure the package has been reinstalled? Maybe try

!pip install "git+https://github.com/pytorch/rl --force-reinstall"

@neuronphysics
Copy link
Author

Unfortunately, I am getting errors. Here is my google colab notebook, in case you would like to reconstruct this error at your end or I installed something before which has triggered this.

@vmoens
Copy link
Contributor

vmoens commented Nov 22, 2022

I managed to install the lib and make it work
There's still a warning from vision, I guess they have a similar issue with python 3.7?

@neuronphysics
Copy link
Author

Thank you so much. YES, it works now.

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

2 participants