<p dir="auto">I'm running on a CentOS ( release 7.4.1708 )  Linux environment that is on a Linux-based HPC. Python version 2.7.</p>
<p dir="auto">I'm running a script to visualize TF-IDF values using the Isomap algorithm ( incorporating sci-kit learns) and then using a 3D scatterplot to visualize possible relationships between tfidf values of a corpus. This has already been preprocessed. This is my code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def Isomap(tfidf):
  jon = pd.read_csv(tfidf)
  le = preprocessing.LabelEncoder()
  tims = jon.apply(le.fit_transform)
  iso = manifold.Isomap(n_neighbors=2, n_components=3)
  john = iso.fit_transform(tims)
  fig = plt.figure(1)
  colors = ['red', 'yellow', 'green']
  ax = fig.add_subplot(111, projection='3d')
  ax.scatter(john[:,0], john[:,1],john[:,2],color=colors,alpha=.5) # x,y,z coord. jon 1-3 
  plt.title('Isomap of candiates')
  plt.xlabel('x')
  plt.ylabel('y')
  plt.show()
  plt.savefig('isomap.png') "><pre class="notranslate"><code class="notranslate">def Isomap(tfidf):
  jon = pd.read_csv(tfidf)
  le = preprocessing.LabelEncoder()
  tims = jon.apply(le.fit_transform)
  iso = manifold.Isomap(n_neighbors=2, n_components=3)
  john = iso.fit_transform(tims)
  fig = plt.figure(1)
  colors = ['red', 'yellow', 'green']
  ax = fig.add_subplot(111, projection='3d')
  ax.scatter(john[:,0], john[:,1],john[:,2],color=colors,alpha=.5) # x,y,z coord. jon 1-3 
  plt.title('Isomap of candiates')
  plt.xlabel('x')
  plt.ylabel('y')
  plt.show()
  plt.savefig('isomap.png') 
</code></pre></div>
<p dir="auto">However, the error code reads as so:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;MasterScript.py&quot;, line 157, in &lt;module&gt;
    Isomap('tfidf.txt')
  File &quot;MasterScript.py&quot;, line 134, in Isomap
    fig = plt.figure(1)
  File &quot;/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/pyplot.py&quot;, line 535, in figure
    **kwargs)
  File &quot;/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py&quot;, line 44, in new_figure_manager
    return new_figure_manager_given_figure(num, thisFig)
  File &quot;/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py&quot;, line 51, in new_figure_manager_given_figure
    canvas = FigureCanvasQTAgg(figure)
  File &quot;/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py&quot;, line 242, in __init__
    super(FigureCanvasQTAgg, self).__init__(figure=figure)
  File &quot;/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py&quot;, line 66, in __init__
    super(FigureCanvasQTAggBase, self).__init__(figure=figure)
  File &quot;/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py&quot;, line 236, in __init__
    _create_qApp()
  File &quot;/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py&quot;, line 144, in _create_qApp
    raise RuntimeError('Invalid DISPLAY variable')
RuntimeError: Invalid DISPLAY variable"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "MasterScript.py", line 157, in &lt;module&gt;
    Isomap('tfidf.txt')
  File "MasterScript.py", line 134, in Isomap
    fig = plt.figure(1)
  File "/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/pyplot.py", line 535, in figure
    **kwargs)
  File "/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 44, in new_figure_manager
    return new_figure_manager_given_figure(num, thisFig)
  File "/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 51, in new_figure_manager_given_figure
    canvas = FigureCanvasQTAgg(figure)
  File "/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 242, in __init__
    super(FigureCanvasQTAgg, self).__init__(figure=figure)
  File "/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 66, in __init__
    super(FigureCanvasQTAggBase, self).__init__(figure=figure)
  File "/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 236, in __init__
    _create_qApp()
  File "/util/common/python/anaconda-5.0.0/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 144, in _create_qApp
    raise RuntimeError('Invalid DISPLAY variable')
RuntimeError: Invalid DISPLAY variable
</code></pre></div>
<p dir="auto">I'm not exactly sure if it is a fault of matplotlib or my own handling of the library. Any help would be appreciated.</p>
<p dir="auto">In my AWS Ubuntu 14.02 instance I installed the matplotlib dependencies and then via pip I installed matplotlib:</p>
<p dir="auto">sudo apt-get build-dep python-matplotlib</p>
<p dir="auto">sudo pip install matplotlib</p>
<p dir="auto">sudo pip freeze:<br>
matplotlib==1.4.0</p>
<p dir="auto">in a brand new file plotting1.py I wrote:</p>
<h1 dir="auto">!/usr/bin/python</h1>
<p dir="auto">from pylab import *<br>
plot([1,2,3])<br>
show()</p>
<p dir="auto">after typying chmod +x plotting1.py, I executed the little script:</p>
<p dir="auto">time python plotting1.py<br>
Traceback (most recent call last):<br>
File "plotting1.py", line 4, in<br>
plot([1,2,3])<br>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 3086, in plot<br>
ax = gca()<br>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 827, in gca<br>
ax = gcf().gca(*_kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 461, in gcf<br>
return figure()<br>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 434, in figure<br>
*_kwargs)<br>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4ag g.py", line 47, in new_figure_manager<br>
return new_figure_manager_given_figure(num, thisFig)<br>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4ag g.py", line 54, in new_figure_manager_given_figure<br>
canvas = FigureCanvasQTAgg(figure)<br>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4ag g.py", line 72, in init<br>
FigureCanvasQT.init(self, figure)<br>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt4.p y", line 68, in init<br>
_create_qApp()<br>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt5.p y", line 139, in _create_qApp<br>
raise RuntimeError('Invalid DISPLAY variable')<br>
RuntimeError: Invalid DISPLAY variable</p>
<p dir="auto">real 0m0.404s<br>
user 0m0.284s</p>
<p dir="auto">What do I have to do now?</p>
<p dir="auto">Looking forward to your kind help.<br>
Kind regards.<br>
Marco</p>