tkinter.TclError: impossible de se connecter pour afficher “localhost:18.0”

J'étais en train d'exécuter une simulation (écrit en python) dans le serveur central, et lorsque la simulation est terminée, déplacez sauvé la figure de fichier /fichier de données enregistrées pour mon PC local, en vous connectant à mon PC local. Le Code est comme suit:

import matplotlib.pyplot as plt
import subprocess
import scipy.io
import os

#Save data file:
scipy.io.savemat(data_path + Filename_str, dict(A=board))

#Create /Save figure by using imshow (Heatmap)
p = plt.imshow(mean_map.T, cmap = plt.cm.gist_yarg_r, origin = 'lower',  extent = [0, phi, 0, Z], aspect='auto')
plt.savefig(figure_path + Filename_str + '-Homophily.pdf')

# Connect to my local host (arabian-knights) using ssh, and follow command.
ret = subprocess.call(['ssh', 'arabian-knights', 'mv Data/* /scratch/Data/'])
ret = subprocess.call(['ssh', 'arabian-knights', 'mv Figure/* /scratch/Figure/'])

J'ai lancer la simulation en arrière-plan de l'ordinateur serveur, après la connexion à l'ordinateur serveur à partir de mon ordinateur local (arabe-les chevaliers). Même si je désactive la connexion au serveur de l'ordinateur, la simulation est en cours d'exécution en arrière-plan, il ne s'arrête pas, et les fichiers de Données sont correctement déplacé à mon ordinateur local après la simulation est effectuée. Cependant, la Figure de fichiers (produit par matplotlib.pyplot.imshow) ne sont pas enregistrées, montrant le message d'erreur suivant:

Traceback (most recent call last):
  File "./ThrHomoHeatmap-thrstep.py", line 179, in <module>
    p = plt.imshow(board.T, cmap = plt.cm.gist_yarg_r, vmin=0, vmax=n, origin = 'lower',  extent = [0, phi, 0, Z], aspect='auto')
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2370, in imshow
    ax = gca()
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 701, in gca
    ax =  gcf().gca(**kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 369, in gcf
    return figure()
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 343, in figure
    **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 80, in new_figure_manager
    window = Tk.Tk()
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1688, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display "localhost:18.0"

Est-il quelqu'un qui peut résoudre ce problème, déplacez matplotlib.pyplot figure des fichiers à partir du serveur vers l'ordinateur local?

OriginalL'auteur user2901339 | 2013-10-22