Gym: Fail to render gym environment in Pyenv installed python

Created on 12 Oct 2018  路  17Comments  路  Source: openai/gym

As context, I'm running all code locally on my Macbook Pro under MacOS Mojave 10.14.

Homebrew recently updated python to 3.7 which is currently not compatible with tensorflow. I reinstalled pyenv so I can manage my active python version and installed tensorflow + ai gym on 3.6.6. When I try to render an environment:

import gym
env = gym.make('CartPole-v0')
env.reset()

for i in range(1000):
    env.step(env.action_space.sample())
    env.render()

I get a blank rendering window when using the pyenv installed interpreter (3.6.6 and 3.7). When I use the hombrew installed intepreter (3.7) the rendering works fine.

Anyone else have this issue? I posted here as any suggestions as to what the majority of the community is using for their development environment (I've used conda, docker, and singularity before) would be welcome.

Most helpful comment

Same problem here after upgrading the OSX to Mojave, any fix for this blank screen issue?

All 17 comments

I can confirm the same issue, in a similar environment (Python 3.7.0 and macOS 10.14). I have tried in a standalone script, called by the python and ipython interpreters, as well as a jupyter session.

In my case, the same problem occurs in both the homebrew-installed Python as well as in a venv module virtual environment. I do not use Anaconda.

venv:
screen shot 2018-10-15 at 5 52 35 pm

system (via homebrew):
screen shot 2018-10-15 at 5 51 17 pm

It is not pictured, but in both cases the mouse is in an infinite "beach ball" loop. I have to kill the kernel/interpreter in all cases.

@mjlbach @damienstanton your issues actually look different to me.
From what I understand, in @mjlbach 's case, rendering works with python 3.7, but does not with 3.6.6 in pyenv; whereas in @damienstanton 's case rendering does not work with with python 3.7.
Unfortunately, I have no good timeline for the fix (we don't have CI set up for osx - blame travis for lack of python support there, and I don't think anyone working on the gym has switched to Mojave just yet). However, @mjlbach , if you are open to use docker, you should have no problems - we have dockerfiles detailing installation on ubuntu 18.04 and 16.04. Also, if you don't want to deal with X forwarding from docker, but still would like to see what agents are going, it is possible to record and save the videos using VideoRecorder (https://github.com/openai/gym/blob/master/gym/wrappers/monitoring/video_recorder.py)
Sorry I cannot be more helpful here, as soon as I have a way to reproduce this, I'll get back to it.

No worries! I just wanted to document the issue. I've been using gym in a docker environment with X forwarding. Thanks for the suggestion about recording videos!

@mjlbach sounds like a great workaround in the meantime. Could you share how you use x forwarding in this case for gym?

Same problem here after upgrading the OSX to Mojave, any fix for this blank screen issue?

+1

Same issue, using Mojave w/ Python 3.7.1

Same issue using Mojave w/ Python 3.7.1

@mjlbach
Can you share how you use

I've been using gym in a docker environment with X forwarding.

Simple pyenv in my local environment

same issue here running python 3.6.4 via pyenv

Same issue. Mojave 10.14.1 with Python 3.7.1.

Edit: Updating to 10.14.2 solved it for me.

Does anyone other than @AL-JShen confirm that after updating to 10.14.2 the issue is fixed ?

@gauthiermartin

https://github.com/openai/gym/issues/1236

Check out this thread, a few others in there have also fixed their problems by updating.

This is great news. Not to be too negative, but I'm very glad that my current Mac laptop is the last Mac I will be using professionally 馃檪

I confirm after updating to 10.14.2 it does work perfectly

Closed because 10.14.2 fixes the issue, and alternative solutions (Docker, rendering to video) were available.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gawne picture Gawne  路  4Comments

tornadomeet picture tornadomeet  路  4Comments

david8373 picture david8373  路  4Comments

Ettrig picture Ettrig  路  3Comments

pdoongarwal picture pdoongarwal  路  4Comments