Skip to content

[Question] import errors of metadrive. #367

@DeepAI-rl

Description

@DeepAI-rl

Required prerequisites

Questions

As I know Omnisafe provides an interface for MetaDrive. After having Omnisafe installed, I proceeded to install the latest MetaDrive environment following the regular installation steps. However, whenever I attempt to run the example code, I'm constantly faced with import errors.

When executing the following installation instructions for Metadrive, an import error still appears. It seems that the issue is caused by the installed versions of the dependency packages.

pip install metadrive
or

git clone https://github.com/metadriverse/metadrive.git
cd metadrive
pip install -e .

The error messages are as follows:

python train_policy.py --algo PPOLag --env SafeMetaDrive
Loading PPOLag.yaml from /home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/omnisafe/utils/../configs/on-policy/PPOLag.yaml
Traceback (most recent call last):
  File "/home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/examples/train_policy.py", line 84, in <module>
    agent = omnisafe.Agent(
  File "/home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/omnisafe/algorithms/algo_wrapper.py", line 73, in __init__
    self._init_algo()
  File "/home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/omnisafe/algorithms/algo_wrapper.py", line 167, in _init_algo
    self.agent: BaseAlgo = registry.get(self.algo)(
  File "/home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/omnisafe/algorithms/base_algo.py", line 48, in __init__
    self._init_env()
  File "/home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/omnisafe/algorithms/on_policy/base/policy_gradient.py", line 64, in _init_env
    self._env: OnPolicyAdapter = OnPolicyAdapter(
  File "/home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/omnisafe/adapter/onpolicy_adapter.py", line 55, in __init__
    super().__init__(env_id, num_envs, seed, cfgs)
  File "/home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/omnisafe/adapter/online_adapter.py", line 71, in __init__
    self._env: CMDP = make(env_id, num_envs=num_envs, device=self._device, **env_cfgs)
  File "/home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/omnisafe/envs/core.py", line 421, in make
    return env_class(env_id, **kwargs)
  File "/home/DeepAI/opt/thesis/multi-constraint/omnisafe_metadrive/omnisafe/envs/meta_drive_env.py", line 86, in __init__
    raise ImportError(
ImportError: Please install MetaDrive to use SafeMetaDrive!                
Install from source: https://github.com/metadriverse/metadrive.                
Install from PyPI: `pip install metadrive`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions