4

When I run matplotlib.pyplot in ipython on python 3.5 over ssh, I get this error message, and I'm not sure what to make of it.

In [1]: import matplotlib

In [2]: from matplotlib import pyplot
Jan 13 10:24:14  python[66770] <Error>: Set a breakpoint at CGSLogError to                catch errors as they are logged.
Jan 13 10:24:14  python[66770] <Error>: This user is not allowed access to the     window system right now.
_RegisterApplication(), FAILED TO establish the default connection to the     WindowServer, _CGSDefaultConnection() is NULL.
Jan 13 10:24:15  python[66770] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Jan 13 10:24:15  python[66770] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Jan 13 10:24:15  python[66770] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Jan 13 10:24:15  python[66770] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Jan 13 10:24:15  python[66770] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Jan 13 10:24:15  python[66770] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Jan 13 10:24:15  python[66770] <Warning>: Invalid Connection ID 0

I have tried reinstalling python completely via anaconda and all the packages separately using pip3 install. Any thoughts?

Lois Keller
  • 141
  • 10
  • 1
    At first glance, it looks like you're trying to use an interactive backend over an ssh connection that doesn't have X-forwarding enabled. If you don't want interactive plots, then use a non-interactive backend (e.g. `import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot` in that order). If you do want to use an interactive backend, try connecting with `ssh -X` or something similar. – Joe Kington Jan 13 '16 at 16:36
  • Using import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot worked beautifully... thank you so much, you increased net happiness of the world. – Lois Keller Jan 13 '16 at 19:57

1 Answers1

3

For those who run across this in the future, I was getting this bug on OSX with a user who hadn't actually logged into their system. A new user was added to an OSX laptop, I ssh'd into it, installed matplotlib over ssh, then tried to graph. The system detected that the user account had never been logged into via the GUI and killed Python.

I'm not sure what exactly in the OS was crashing Python, but simply logging into that user account via the GUI (and following the user account setup tutorial, which I think is key) solved the problem for me.

Jason Parham
  • 466
  • 6
  • 10