-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Invalid DISPLAY variable #3466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do you have the X server running? What is your DISPLAY environment variable set to ( |
Hi, echo $DISPLAY so it say nothing What do I have to do to make X server running in my AWS Ubuntu 12.04 instance? Do you know how to set the DISPLAY environment variable to disp? |
Solved. I cannot visualize graphs on AWS server. Thanks for your kind help. |
I had the same problem and I solved it by adding |
@LinZichuan I encoutered this problem too and your solution works. Thanks for your sharing! |
For the record it's better to chose a backend before importing pyplot i.e. import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt |
@LinZichuan Great! It works |
For me on AWS ec2 instance
|
@jenshnielsen
|
I have modified as you suggested, by replacing
|
@hana9090 That is not how the library works. |
For others having this issue: for me it was solved by putting the
all the way at the top of the file it was used in. Initially I though "hmm, it should be fine as long as I put it above all other matplotlib stuff", but nope! It had to be all the way on the top for it to work. |
@teuneboon It must be above anything that imports pyplot. |
@LinZichuan Thanks for sharing!!! It works for me 😆 ! |
@LinZichuan I encountered this problem too and it works for me, Thanks for sharing! Mark! |
@tacaswell Iam also having the same problem of visualizing the output using plt.show() ,when used plt.switch_backend().How to solve this issue. |
switch_backend() probably won't work (although we are working on
improvements to make it possible under certain situations).
It would be hard to figure out your problem without more information. What
OS? Which version of matplotlib? And how did you install matplotlib?
…On Fri, Nov 17, 2017 at 1:03 AM, sulth ***@***.***> wrote:
@tacaswell <https://github.com/tacaswell> Iam also having the same
problem of visualizing the output using plt.show() ,when used
plt.switch_backend().How to solve this issue.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3466 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-JXhKsPiygGvkoT87tF5oL3e5X98ks5s3SG4gaJpZM4CeU7q>
.
|
Hi Thanks !i got it.it was due to agg (non interactive visualisation env).replaced it with qt4agg (interactive)and it worked |
import matplotlib.pyplot as plt
plt.switch_backend('agg') # Very Important in R Markdown That works for me in R Markdown |
Is there any other method where matplotlib plots and shows over ssh or manually saving is the only option?? |
If the server you are logging into does not have xserver running in some
form or another, then, no you can't get a GUI window since the GUI window
would have to come from the server you are logging into. But, usually,
xserver is available on most systems, and usually, doing `ssh -X ...` (or
sometimes, ssh -Y ...` is sufficient to make this work when logging into a
remote server. I should note that I have experienced issues with my CentOS7
machine, and I suspect it has to do with some weird interaction with
SELinux and plymouth. But in general, it should work if you include "-X"
option for your ssh calls.
Note, if you are making multiple ssh hops, each one of those hops will need
the -X option invoked.
…On Tue, May 22, 2018 at 12:05 AM, Naman Jain ***@***.***> wrote:
Is there any other method where matplotlib plots and shows over ssh or
manually saving is the only option??
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3466 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-MPLDuO4AH3Y4IBudfnGR22ZqXsAks5t046MgaJpZM4CeU7q>
.
|
This demo doesn't work on my Linux machine because it doesn't declare a backend for matplotlib. With this change it can now work on my server. This seems to be a common issue as described here: matplotlib/matplotlib#3466
This demo doesn't work on my Linux machine because it doesn't declare a backend for matplotlib. With this change it can now work on my server. This seems to be a common issue as described here: matplotlib/matplotlib#3466
^ Solved the problem for me. Thanks @jenshnielsen . |
Switching to 'agg' does solve the issue. Although I am back stuck at this issue: #12074 |
Explicitly specifying matplotlib backend, which according to this issue on GitHub: matplotlib/matplotlib#3466 should fix the problem with the DISPLAY env variable being invalid on some systems.
In my AWS Ubuntu 14.02 instance I installed the matplotlib dependencies and then via pip I installed matplotlib:
sudo apt-get build-dep python-matplotlib
sudo pip install matplotlib
sudo pip freeze:
matplotlib==1.4.0
in a brand new file plotting1.py I wrote:
!/usr/bin/python
from pylab import *
plot([1,2,3])
show()
after typying chmod +x plotting1.py, I executed the little script:
time python plotting1.py
Traceback (most recent call last):
File "plotting1.py", line 4, in
plot([1,2,3])
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 3086, in plot
ax = gca()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 827, in gca
ax = gcf().gca(*_kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 461, in gcf
return figure()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 434, in figure
*_kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4ag g.py", line 47, in new_figure_manager
return new_figure_manager_given_figure(num, thisFig)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4ag g.py", line 54, in new_figure_manager_given_figure
canvas = FigureCanvasQTAgg(figure)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4ag g.py", line 72, in init
FigureCanvasQT.init(self, figure)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4.p y", line 68, in init
_create_qApp()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt5.p y", line 139, in _create_qApp
raise RuntimeError('Invalid DISPLAY variable')
RuntimeError: Invalid DISPLAY variable
real 0m0.404s
user 0m0.284s
What do I have to do now?
Looking forward to your kind help.
Kind regards.
Marco
The text was updated successfully, but these errors were encountered: