Error when calling `makeEnvironment` after start of Rstudio
markusdumke opened this issue · 5 comments
When I start RStudio and run
library(reinforcelearn)
makeEnvironment("CartPole-v0")
I get the error Error in curl::curl_fetch_memory(url, handle = handle) :
Couldn't connect to server.
If I then just repeat makeEnvironment("CartPole-v0")
again, it works fine. Why does this happen and how to solve this? Does this problem only appears on my computer or can other replicate this as well?
I have met the same error on "Cart.." and other type of errors on other gym name
What other errors? I always get the same type of error. I think is has something to do with the call to system2() in makeEnvironment which starts a Python script. But not sure what to change to resolve this.
Still unsolved
@smilesun
I think it is best to move the code outside of makeEnvironment
because everytime it is inside a function, it will fail. So the user then has to run:
package.path = system.file(package = "reinforcelearn")
path2pythonfile = paste0(package.path, "/gym_http_server.py")
system2("python", args = path2pythonfile, stdout = NULL, wait = FALSE)
client = gym::create_GymClient("http://127.0.0.1:5000")
instance.id = gym::env_create(client, "CartPole-v0")
env = makeEnvironment(list(client, instance.id), render = FALSE)
Can you test if this works for you?
Edit: Ok, still doesn't work, this puzzles me.
Using reticulate this can now be closed.
makeEnvironment("gym", "MountainCar-v0")