3

I have a environment which has the custom architecture like this:

class environment(gym.Env):
    metadata ={'render.modes': ['human']}
    
    
    ACTION = ['buy', 'do not buy']
    
    def __init__(self, df):        
        pass
    
    
    def reset(self):
        #Reset the state of the environment to an initial state   
        return self._next_observation()
    
    
    def step(self, action):
        pass
    
    def _next_observation(self):
        pass
    
    
    def _get_reward(self):
        pass
        
    def _take_action(self, action):
        pass
        
    def render(self, mode = 'human', close=False):
        pass

When creating a package by creating folder system like this

----- env

---------- env

---------- init.py

---------- setup.py

--------------- env.py

--------------- __init__py

I receive my package with pip install -e . I get my custom environment. However, when trying to retrieve my environment by gym.make('env-v0') I get the following traceback:



  File "C:\UsersAW\Desktop\ImitationLearning\Fruit\Fruit\train_reinforcement_learning-fruits.py", line 11, in <module>
    env = gym.make('FruitEnv-v0')

  File "C:\UserAW\Anaconda3\lib\site-packages\gym\envs\registration.py", line 145, in make
    return registry.make(id, **kwargs)

  File "C:\UsersAW\Anaconda3\lib\site-packages\gym\envs\registration.py", line 90, in make
    env = spec.make(**kwargs)

  File "C:\UsersAW\Anaconda3\lib\site-packages\gym\envs\registration.py", line 59, in make
    cls = load(self.entry_point)

  File "C:\UsersAW\Anaconda3\lib\site-packages\gym\envs\registration.py", line 17, in load
    mod_name, attr_name = name.split(":")

ValueError: not enough values to unpack (expected 2, got 1)

Can someone tell me what's missing?

Sunshine
  • 181
  • 1
  • 3
  • 15

1 Answers1

1

It worked after I changed the "entry_point"-argument in the '_ _ _init_ _ _.py' file from

entry_point = 'your_env_folder.envs.name_of_your_env_file.py'

to

entry_point = 'your_env_folder.envs:NameOfYourEnv'
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Guest_27
  • 11
  • 1