简体   繁体   English

注册OpenAI Gym Environment时环境不存在

[英]Environment Does Not Exist When Registering OpenAI Gym Environment

I am trying to register a custom gym environment on a remote server, but it is not working.我正在尝试在远程服务器上注册自定义健身房环境,但它不起作用。 I have been able to successfully register this environment on my personal computer using the Anaconda package manager framework, but have so far been unsuccesful without Anaconda (so I know the problem is not my environment).我已经能够使用 Anaconda 包管理器框架在我的个人计算机上成功注册这个环境,但是到目前为止没有 Anaconda 是不成功的(所以我知道问题不是我的环境)。 To try and work through this problem, I followed this tutorial .为了尝试解决这个问题,我遵循了这个教程

Here is my file structure:这是我的文件结构:

gym-knot
│   setup.py  
│
└───gym_knot
    │   __init__.py
    │   
    └───envs
        │   __init__.py
        │   sliceenv.py

Where gym-knot/setup.py is gym-knot/setup.py在哪里

from setup tools import setup

setup(name='gym_knot', version='0.0.1', install_requires=['gym'] 

gym-knot/gym_knot/__init__.py is gym-knot/gym_knot/__init__.py

from gym.envs.registration import register

register(
   id='Slice-v0',
   entry_point='gym_knot.envs:SliceEnv',
   max_episode_steps=300,
   reward_threshold=0,)

gym-knot/gym_knot/envs/__init__.py is gym-knot/gym_knot/envs/__init__.py

from gym_knot.envs.sliceenv import SliceEnv

I then ran pip install --user -e gym-knot to install it.然后我运行pip install --user -e gym-knot来安装它。

I have import gym_knot in the python file with my algorithm.我用我的算法在 python 文件中import gym_knot

When I use the command python3 knot_project.py (which is the python file with my algorithm and whatnot), I get the error:当我使用命令python3 knot_project.py (这是我的算法和诸如此类的 python 文件)时,我收到错误:

gym.error.NameNotFound: Environment 'gym_knot:Slice' doesn't exist.

I am really confused why I am getting this error because I followed the tutorial exactly and have also look at other resources that told me the same thing.我真的很困惑为什么会收到此错误,因为我完全按照教程进行操作,并且还查看了其他告诉我同样事情的资源。 Am I missing something?我错过了什么吗? Could it be because my knot_project.py file is not in the gym-knot folder so it does not know that my environment exists?可能是因为我的knot_project.py文件不在gym-knot文件夹中,所以它不知道我的环境存在吗? Any help would be appreciated.任何帮助,将不胜感激。

This started happening to me after I upgraded gym from version 0.21 to 0.23, no solution yet but a good clue在我将健身房从 0.21 版升级到 0.23 版后,这开始发生在我身上,还没有解决方案,但一个很好的线索

[Update] It looks like it was a broken update [更新] 看来是更新失败了

Download the zip file for 0.24.0 (or higher) for OpenAI from https://github.com/openai/gym/releases and manually install this version with pip install path/to/dirhttps://github.com/openai/gym/releases下载 OpenAI 的 0.24.0(或更高版本)的 zip 文件,并使用pip install path/to/dir手动安装此版本

See Re-added gym.make("MODULE:ENV") import style that was accidentally removed in v0.22 @arjun-kg comment on patch notes请参阅Re-added gym.make("MODULE:ENV") import style that was accidentally removed in v0.22 @arjun-kg对补丁说明的评论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM