[Python] Module 'numpy' has no attribute 'bool8' In cartpole problem openai gym

Discussão em 'Python' iniciado por Stack, Outubro 6, 2024.

  1. Stack

    Stack Membro Participativo

    I'm beginner & trying to run this simple code but it is giving me this exception "module 'numpy' has no attribute 'bool8'" as you can see in screenshot below. Gym version is 0.26.2 & numpy version is 2.1.1. I've tried downgrading both but visual studio won't let me do that. I have installed latest verison of everything and I know this is happening because the newer version doesn't allow the use of bool8 instead using bool_ will help but i don't know where should i change bool8 to bool_ i can't see this in my code. How can i make it work?

    [​IMG]

    import gym

    # Create the CartPole environment
    env = gym.make('CartPole-v1')

    # Reset the environment to start
    state = env.reset()

    # Run for 1000 timesteps
    for _ in range(1000):
    env.render() # Render the environment
    action = env.action_space.sample() # Take a random action
    state, reward, done, info = env.step(action) # Step the environment by one timestep

    # If the episode is done (CartPole has fallen), reset the environment
    if done:
    state = env.reset()

    env.close() # Close the rendering window


    On clicking show call stack it shows this :-

    [​IMG]

    Continue reading...

Compartilhe esta Página