Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question MlAgents numpy error on Macos

Discussion in 'ML-Agents' started by ko_engineering, Aug 30, 2023.

  1. ko_engineering

    ko_engineering

    Joined:
    Aug 30, 2023
    Posts:
    1
    Hello,
    I am new to MlAgents. I am using an macbook pro with Ventura. I am using Unity version 2022.3.4. When I try to train my agent, I get this error. I have tried changing the np.bool to bool, and have tried using conda and a virtual environment. I have also tried downgrading numpy to 1.24.3, but the same error pops up. When I try to update numpy, it says that it fails to download. I also updated Mlagents package.
    Here is the error
    /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents_envs/rpc_utils.py:376: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.

    dtype=np.bool,

    [ERROR] UnityEnvironment worker 0: environment raised an unexpected exception.

    Traceback (most recent call last):

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents/trainers/subprocess_env_manager.py", line 211, in worker

    env.reset()

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents_envs/environment.py", line 325, in reset

    self._update_state(rl_output)

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents_envs/environment.py", line 306, in _update_state

    self._env_state[brain_name] = steps_from_proto(

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents_envs/timers.py", line 305, in wrapped

    return func(*args, **kwargs)

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents_envs/rpc_utils.py", line 376, in steps_from_proto

    dtype=np.bool,

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__

    raise AttributeError(__former_attrs__[attr])

    AttributeError: module 'numpy' has no attribute 'bool'.

    `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.

    The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:

    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

    Traceback (most recent call last):

    File "/Library/Frameworks/Python.framework/Versions/3.8/bin/mlagents-learn", line 10, in <module>

    sys.exit(main())

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 260, in main

    run_cli(parse_command_line())

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 256, in run_cli

    run_training(run_seed, options, num_areas)

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 132, in run_training

    tc.start_learning(env_manager)

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents_envs/timers.py", line 305, in wrapped

    return func(*args, **kwargs)

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents/trainers/trainer_controller.py", line 173, in start_learning

    self._reset_env(env_manager)

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents_envs/timers.py", line 305, in wrapped

    return func(*args, **kwargs)

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents/trainers/trainer_controller.py", line 105, in _reset_env

    env_manager.reset(config=new_config)

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents/trainers/env_manager.py", line 68, in reset

    self.first_step_infos = self._reset_env(config)

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents/trainers/subprocess_env_manager.py", line 446, in _reset_env

    ew.previous_step = EnvironmentStep(ew.recv().payload, ew.worker_id, {}, {})

    File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mlagents/trainers/subprocess_env_manager.py", line 101, in recv

    raise env_exception

    AttributeError: module 'numpy' has no attribute 'bool'.

    `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.

    The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:

    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations