<legend id='lBIft'><style id='lBIft'><dir id='lBIft'><q id='lBIft'></q></dir></style></legend>

    <small id='lBIft'></small><noframes id='lBIft'>

      <bdo id='lBIft'></bdo><ul id='lBIft'></ul>

  1. <tfoot id='lBIft'></tfoot>

    1. <i id='lBIft'><tr id='lBIft'><dt id='lBIft'><q id='lBIft'><span id='lBIft'><b id='lBIft'><form id='lBIft'><ins id='lBIft'></ins><ul id='lBIft'></ul><sub id='lBIft'></sub></form><legend id='lBIft'></legend><bdo id='lBIft'><pre id='lBIft'><center id='lBIft'></center></pre></bdo></b><th id='lBIft'></th></span></q></dt></tr></i><div id='lBIft'><tfoot id='lBIft'></tfoot><dl id='lBIft'><fieldset id='lBIft'></fieldset></dl></div>
    2. tkinter.TclError:无法连接以显示“localhost:18.0"

      时间:2023-07-21
      <legend id='LkUc1'><style id='LkUc1'><dir id='LkUc1'><q id='LkUc1'></q></dir></style></legend><tfoot id='LkUc1'></tfoot>
      <i id='LkUc1'><tr id='LkUc1'><dt id='LkUc1'><q id='LkUc1'><span id='LkUc1'><b id='LkUc1'><form id='LkUc1'><ins id='LkUc1'></ins><ul id='LkUc1'></ul><sub id='LkUc1'></sub></form><legend id='LkUc1'></legend><bdo id='LkUc1'><pre id='LkUc1'><center id='LkUc1'></center></pre></bdo></b><th id='LkUc1'></th></span></q></dt></tr></i><div id='LkUc1'><tfoot id='LkUc1'></tfoot><dl id='LkUc1'><fieldset id='LkUc1'></fieldset></dl></div>
          <bdo id='LkUc1'></bdo><ul id='LkUc1'></ul>

                <tbody id='LkUc1'></tbody>

              <small id='LkUc1'></small><noframes id='LkUc1'>

                本文介绍了tkinter.TclError:无法连接以显示“localhost:18.0"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我试图在中央服务器中运行模拟(用 python 编写),模拟完成后,通过连接到我的本地 PC 将保存的图形文件/保存的数据文件移动到我的本地 PC.代码如下:

                I was trying to run a simulation (written in python) in the central server, and when simulation is finished, move saved figure file / saved data file to my local PC, by connecting to my local PC. Code is as following:

                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/'])
                

                从我的本地计算机(阿拉伯骑士)连接到服务器计算机后,我在服务器计算机的后台运行此模拟.即使我关闭了与服务器计算机的连接,因为模拟在后台运行,它不会停止,并且在模拟完成后数据文件会正确移动到我的本地计算机.但是,图形文件(由 matplotlib.pyplot.imshow 生成)没有保存,显示以下错误消息:

                I run this simulation in background of server computer, after connecting to server computer from my local computer (arabian-knights). Even though I turn off connection to server computer, as simulation is running in background, it doesn't stop, and Data files are correctly moved to my local computer after simulation is done. However, Figure files (produced by matplotlib.pyplot.imshow) are not saved, showing following error messsage:

                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"
                

                有没有人可以解决这个问题,将matplotlib.pyplot图形文件也从服务器移动到本地计算机?

                Is there anyone who can solve this problem, to move matplotlib.pyplot figure files from server to local computer as well?

                推荐答案

                问题是您正在使用一个交互式后端,它试图为您创建图形窗口,但由于您断开了之前的 x-server开始模拟时可用.

                The problem is that you are using an interactive backend which is trying to create figure windows for you, which are failing because you have disconnected the x-server that was available when you started the simulations.

                将您的导入更改为

                import matplotlib
                matplotlib.use('pdf')
                import matplotlib.pyplot as plt
                

                这篇关于tkinter.TclError:无法连接以显示“localhost:18.0"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:从 gevent-subprocess 获取实时标准输出? 下一篇:Python subprocess.Popen() 等待完成

                相关文章

                <small id='BUcsU'></small><noframes id='BUcsU'>

              1. <legend id='BUcsU'><style id='BUcsU'><dir id='BUcsU'><q id='BUcsU'></q></dir></style></legend>
                <i id='BUcsU'><tr id='BUcsU'><dt id='BUcsU'><q id='BUcsU'><span id='BUcsU'><b id='BUcsU'><form id='BUcsU'><ins id='BUcsU'></ins><ul id='BUcsU'></ul><sub id='BUcsU'></sub></form><legend id='BUcsU'></legend><bdo id='BUcsU'><pre id='BUcsU'><center id='BUcsU'></center></pre></bdo></b><th id='BUcsU'></th></span></q></dt></tr></i><div id='BUcsU'><tfoot id='BUcsU'></tfoot><dl id='BUcsU'><fieldset id='BUcsU'></fieldset></dl></div>

                      <bdo id='BUcsU'></bdo><ul id='BUcsU'></ul>

                    <tfoot id='BUcsU'></tfoot>