Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running a python script on a remote server via SSH, however at the end I require it to save a graph using pyplot, which requires the X server to be active. As this runs for a long time I have been using the "screen" command and leaving it then resuming when I come back. The problem with this is that the resumed screen attempts to output to whatever X display SSH was using the first time I connected (e.g. localhost:15.0) however often by the time I return either the local machine or the server has assigned me a different one (e.g. localhost:22.0) and so the code breaks as it can't find anywhere to output.

Is there any way I can stop this timing out or set which display I wish to use from within the SSH session? I have tried connecting using -X and -Y and there is no change?

Thanks!

share|improve this question

1 Answer 1

To start, you'd probably be better off just using some other plotting library like matplotlib which doesn't require an X framebuffer.

If you absolutely must use pyplot, try starting up Xvfb (a virtual X server) on the remote end and point the $DISPLAY variable at it instead of the forwarded X display. That way it will run inside the screen without problems.

share|improve this answer
    
I was under the impression matplotlib's plotting WAS pyplot? –  Mithra Apr 17 '12 at 16:41
    
Er, sorry, I meant to use another library call that doesn't require an X framebuffer, like savefig(). –  jsbillings Apr 17 '12 at 16:44
    
Will try the Xvfb method. I'm only trying to save the figure rather than outputting it however even creating a subplot in pyplot seems to require X. –  Mithra Apr 17 '12 at 16:57
    
Fixed it! Thanks for the help, Xvfb didn't exist on the server I needed to use but changed the backend matplotlib uses to Agg and that did the trick. Cheers again for the advice. –  Mithra Apr 17 '12 at 17:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.