Farama-Foundation / Gymnasium

An API standard for single-agent reinforcement learning environments, with popular reference environments and related utilities (formerly Gym)
https://gymnasium.farama.org
MIT License
6.4k stars 731 forks source link

[Question] I'm not able to make a custom env, am I doing something wrong? #653

Closed theunluckyguy closed 11 months ago

theunluckyguy commented 11 months ago

Question

``Hello everyone, I anticipate that I'm a beginner but I'm having this problem since a while and I feel frustrated... I'm trying to build a custom envorinment (in Colab) for some university assignment and I'm doing the following:

!pip install gymnasium
import gymnasium as gym

!pip install -e tradingEnvironmentPackage

I want to precise that I built the Environment as said on the Gymnasium Documentation.

from tradingEnvironmentPackage import trading_environment
from gym import envs
print(envs.registry.values())

And here I see my environment in the output with the ID TradingEnv-v0. But when I try the following:

env = gym.make('TradingEnv-v0')

I receive: NameNotFound: Environment TradingEnv doesn't exist.

pseudo-rnd-thoughts commented 11 months ago

Could you print the keys instead of values, i.e., envs.registry.values()

theunluckyguy commented 11 months ago

Hello Mark, thanks for your answer! I just tried and this is what I get:

dict_keys(['CartPole-v0', 'CartPole-v1', 'MountainCar-v0', 'MountainCarContinuous-v0', 'Pendulum-v1', 'Acrobot-v1', 'LunarLander-v2', 'LunarLanderContinuous-v2', 'BipedalWalker-v3', 'BipedalWalkerHardcore-v3', 'CarRacing-v2', 'Blackjack-v1', 'FrozenLake-v1', 'FrozenLake8x8-v1', 'CliffWalking-v0', 'Taxi-v3', 'Reacher-v2', 'Reacher-v4', 'Pusher-v2', 'Pusher-v4', 'InvertedPendulum-v2', 'InvertedPendulum-v4', 'InvertedDoublePendulum-v2', 'InvertedDoublePendulum-v4', 'HalfCheetah-v2', 'HalfCheetah-v3', 'HalfCheetah-v4', 'Hopper-v2', 'Hopper-v3', 'Hopper-v4', 'Swimmer-v2', 'Swimmer-v3', 'Swimmer-v4', 'Walker2d-v2', 'Walker2d-v3', 'Walker2d-v4', 'Ant-v2', 'Ant-v3', 'Ant-v4', 'Humanoid-v2', 'Humanoid-v3', 'Humanoid-v4', 'HumanoidStandup-v2', 'HumanoidStandup-v4', 'TradingEnv-v0'])

As you can see at the end I have TradingEnv-v0

pseudo-rnd-thoughts commented 11 months ago

Ohh, you are using gym to check the registry then trying to make the environment using gymnasium. If you do

import gymnasium
import gym

print("gymnasium", gymnasium.envs.registry.keys())
print("gym", gym.envs.registry.keys())

you will see that the environment exists in the gym one and not the gymnasium one

It seems that the package needs to update the gymnasium for you to use gymnasium otherwise you are stuck using gym