Git Product home page Git Product logo

gym.jl's Introduction

Gym

Build Status

This package provides a julia interface for OpenAi gym.

Installation

In pkg repl,

add Gym

If you do not have a gym installation. The package will install it for you with the following command:

build Gym

This makes a minimal installation of the gym. If you want to install free environments, you should set the GYM_ENVS environment variable as following:

ENV["GYM_ENVS"]="atari:algorithmic:box2d:classic_control"

Then call the build Gym.

Usage

using Gym

env = GymEnv("CartPole-v0")
reward = 0
episode_count = 10

for i=1:episode_count
    total = 0
    ob = reset!(env)
    render(env)#comment out this line if you do not want to visualize the environment
    while true
        action = sample(env.action_space)
        ob, reward, done, information = step!(env, action)
        total += reward
        render(env)#comment out this line if you do not want to visualize the environment
        done && break
    end
    println("episode $i total Rewards: $total")
end

gym.jl's People

Contributors

ozanarkancan avatar juliatagbot avatar

Stargazers

Nick Imanzi avatar Andrea PIERRÉ avatar shg avatar ChangXin Sun avatar Da avatar Lor avatar Haoxuan (Horace) Wang avatar Kai Xu avatar Kartikey Gupta avatar Peter avatar  avatar AStupidBear avatar Tomas Mikoviny avatar Carlo Lucibello avatar

Watchers

James Cloos avatar  avatar Andrea PIERRÉ avatar

gym.jl's Issues

KeyError: key "tags" not found

I'm trying to run the Gym as shown in the README, but:

julia> env = GymEnv("CartPole-v0")
ERROR: KeyError: key "tags" not found
Stacktrace:
 [1] getproperty(::PyCall.PyObject, ::String) at /home/jstrube/.julia/packages/PyCall/zqDXB/src/PyCall.jl:301
 [2] getproperty(::PyCall.PyObject, ::Symbol) at /home/jstrube/.julia/packages/PyCall/zqDXB/src/PyCall.jl:306
 [3] GymEnv(::String) at /home/jstrube/.julia/packages/Gym/QZ2GY/src/env.jl:21
 [4] top-level scope at REPL[2]:1

I'm trying this with Gym v1.1.3.

julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

ERROR: LoadError

Is this an issue on my end or GitHub?

ERROR: LoadError: IOError: could not spawn git clone https://github.com/openai/gym.git: no such file or directory (ENOENT)

Thanks.

build problem

Hi,
I didn't have the python gym package installed, and Gym.jl failed for me due to a denied user permission when using pip. Attempting a local install with

pip install --user  gym

might be a better option for Gym.jl

installation problem

julia> pkg"add Gym"
  Resolving package versions...
Updating `/userfiles/dyuret/.julia/environments/v1.5/Project.toml`
  [b0807396] + Gym v1.1.4
Updating `/userfiles/dyuret/.julia/environments/v1.5/Manifest.toml`
  [b0807396] + Gym v1.1.4

julia> pkg"build Gym"
   Building Conda ─→ `/userfiles/dyuret/.julia/packages/Conda/x5ml4/deps/build.log`
   Building PyCall → `/userfiles/dyuret/.julia/packages/PyCall/BcTLp/deps/build.log`
   Building Gym ───→ `/userfiles/dyuret/.julia/packages/Gym/exeFO/deps/build.log`
┌ Error: Error building `Gym`:
│ ERROR: LoadError: LoadError: parsing command `pip install --user -e .[$env]`: special characters "#{}()[]<>|&*?~;" must be quoted$
│ Stacktrace:
│  [1] error(::String) at ./error.jl:33
│  [2] shell_parse(::String, ::Bool; special::String) at ./shell.jl:100
│  [3] @cmd(::LineNumberNode, ::Module, ::Any) at ./cmd.jl:389
│  [4] include(::String) at ./client.jl:457
│  [5] top-level scope at none:5
│ in expression starting at /userfiles/dyuret/.julia/packages/Gym/exeFO/deps/build.jl:6
│ in expression starting at /userfiles/dyuret/.julia/packages/Gym/exeFO/deps/build.jl:1
└ @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Operations.jl:949
julia> versioninfo()
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2695 v4 @ 2.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, broadwell)
Environment:
  JULIA_CUDA_USE_BINARYBUILDER = true
  JULIA_REVISE_POLL = 1
  JULIA_DEPOT_PATH = /userfiles/dyuret/.julia:
  JULIA_REVISE = manual
  JULIA_PKG_DEVDIR = /userfiles/dyuret/.julia/dev

Tons of warnings/deprecated calls

When I am using this I get a huge terminal full of warnings at the beginning. It still works so I guess this isn't a big deal but it would be nice to know that the wrapper is up to date.

update readme

readme should reflect registration on metadata in the install instructions: Pkg.add("Gym")

Unable to load Lunar lander environment

env = GymEnv("LunarLander-v2")
gives


ERROR: Error received during the initialization of LunarLander-v2
PyError ($(Expr(:escape, :(ccall(#= /Users/dpk/.julia/packages/PyCall/0jMpb/src/pyfncall.jl:44 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'pyglet'",)
  File "/Users/dpk/.julia/packages/Gym/pgnnb/deps/gym/gym/envs/registration.py", line 171, in make
    return registry.make(id, **kwargs)
  File "/Users/dpk/.julia/packages/Gym/pgnnb/deps/gym/gym/envs/registration.py", line 123, in make
    env = spec.make(**kwargs)
  File "/Users/dpk/.julia/packages/Gym/pgnnb/deps/gym/gym/envs/registration.py", line 86, in make
    cls = load(self._entry_point)
  File "/Users/dpk/.julia/packages/Gym/pgnnb/deps/gym/gym/envs/registration.py", line 14, in load
    result = entry_point.resolve()
  File "/Users/dpk/.julia/conda/3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2352, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Users/dpk/.julia/packages/Gym/pgnnb/deps/gym/gym/envs/box2d/__init__.py", line 4, in <module>
    from gym.envs.box2d.car_racing import CarRacing
  File "/Users/dpk/.julia/packages/Gym/pgnnb/deps/gym/gym/envs/box2d/car_racing.py", line 12, in <module>
    import pyglet

on Julia 1.0
This occurred after setting ENV["GYM_ENVS"]="atari:algorithmic:box2d:classic_control" and doing build Gym

"no such file" error on package add

Command ] add Gym throws the following error in julia 1.1:

Error: Error building Gym:
│ ┌ Warning: special characters "#{}()[]<>|&*?~;" should now be quoted in commands
│ │ caller = #shell_parse#351(::String, ::Function, ::String, ::Bool) at shell.jl:100
│ └ @ Base .\shell.jl:100
│ [ Info: Downloading OpenAi gym
│ ERROR: LoadError: IOError: could not spawn git clone https://github.com/openai/gym.git: no such file or directory (ENOENT)
│ Stacktrace:
│ [1] _spawn_primitive(::String, ::Cmd, ::Array{Any,1}) at .\process.jl:400
│ [2] #505 at .\process.jl:413 [inlined]
│ [3] setup_stdios(::getfield(Base, Symbol("##505#506")){Cmd}, ::Array{Any,1}) at .\process.jl:497
│ [4] _spawn at .\process.jl:412 [inlined]
│ [5] #run#515(::Bool, ::Function, ::Cmd) at .\process.jl:725
│ [6] run(::Cmd) at .\process.jl:724
│ [7] top-level scope at C:\Users\Henri.julia\packages\Gym\GnwvQ\deps\build.jl:43
│ [8] include at .\boot.jl:326 [inlined]
│ [9] include_relative(::Module, ::String) at .\loading.jl:1038
│ [10] include(::Module, ::String) at .\sysimg.jl:29
│ [11] include(::String) at .\client.jl:403
│ [12] top-level scope at none:0
│ in expression starting at C:\Users\Henri.julia\packages\Gym\GnwvQ\deps\build.jl:31
└ @ Pkg.Operations C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\Pkg\src\Operations.jl:1075

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.