How to resolve 'universe module not found' ImportError in Python?

I’m trying to create a training bot for a gym environment but keep running into module import issues

Hey everyone! I’ve been working on a machine learning project where I want to build a bot that can learn from gym environments. However, when I try to run my script, I get this frustrating error: ImportError: No module named universe

I’m not sure what’s causing this problem or how to fix it properly. Has anyone faced something similar before?

Here’s the code I’m using:

import gym
import universe

my_env = gym.make('BlockPuzzle-v0')
state = my_env.reset()

while True:
    moves = [[('KeyEvent', 'ArrowRight', True)] for s in state]
    state, score, finished, info = my_env.step(moves)
    my_env.render()

I’m running this on a Windows machine with Python installed. Any suggestions on what might be going wrong here? Thanks in advance for any help!

The universe module got deprecated and OpenAI doesn’t maintain it anymore. I hit this exact issue two years back on a similar project. They basically abandoned it around 2018 and it won’t install on modern Python versions. You’ll want to switch to alternatives like Stable Baselines3 or PettingZoo - they do the same RL agent training stuff. For browser environments specifically, try Selenium WebDriver with standard gym environments. I made the switch myself and honestly, the newer libraries have way better docs and community support than universe ever had.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.