NoSuchDisplayException: Cannot connect to "None"


#1

####Is there anyone can help me? ####

When I execute these two lines of code (ssh access to ubuntu 14.04 with python 3.5):

 env = gym.make('CartPole-v0')
  screen = env.render(mode='rgb_array').transpose((2,0,1))

The error of NoSuchDisplayException: Cannot connect to “None” is arisen?

I do not know how to fix it.

Actually, I want get the an numpy array of raw pixels in the the “CartPole-v0” game after every action being taken. How to do to achieve this?


#2

That is because you didn’t setup x11 forwarding

env.render() will display a window, that need to be forward to your client,

after x11 forwarding, you will get the window rendered at you client(e.g Windows/Mac)