2013-10-11 58 views
27

我試圖運行一個非常簡單的代碼,在集羣中輸出一個.png文件。下面的代碼:

Unable to load library icui18n "Cannot load library icui18n: 

的PNG圖片仍然產生這樣:

import matplotlib.pyplot as plt 
import numpy as np 

x = np.random.randn(60) 
y = np.random.randn(60) 

plt.scatter(x, y, s=20) 

out_png = 'path/to/store/out_file.png' 
plt.savefig(out_png, dpi=150) 

如果我已經matplotlib安裝1.2.1我得到警告我的系統命令python simple_code.py運行這段代碼我在這裏沒有問題。但是,如果使用相同的命令和代碼中已matplotlib 1.3.0羣集安裝失敗,出現錯誤:

Traceback (most recent call last): 
    File "simple_code.py", line 33, in <module> 
    plt.scatter(x, y, s=20) 
    File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 3078, in scatter 
    ax = gca() 
    File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 803, in gca 
    ax = gcf().gca(**kwargs) 
    File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf 
    return figure() 
    File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in figure 
    **kwargs) 
    File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 79, in new_figure_manager 
    return new_figure_manager_given_figure(num, figure) 
    File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 87, in new_figure_manager_given_figure 
    window = Tk.Tk() 
    File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__ 
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) 
_tkinter.TclError: no display name and no $DISPLAY environment variable 

這到底是怎麼回事?


添加,這是我用來登錄到集羣的腳本:

#!/usr/bin/expect 

set login "user" 
set addr "address1" 
set addr2 "address2" 
set pw "password" 

spawn ssh -X $log[email protected]$addr 
expect "[email protected]$addr\'s password:" 
send "$pw\r" 
expect "[email protected]:" 
send "ssh -X $addr2\r" 
expect "[email protected]$addr\'s password:" 
send "$pw\r" 
interact 
+2

你是通過'ssh'運行這個嗎? – SethMMorton

+1

是的,我是SethMMorton。我設置了這個工作並讓它通過'ssh'在集羣中運行。 – Gabriel

+3

當你調用'ssh'時,你使用'-X'標誌嗎? – SethMMorton

回答

33

你的問題,是SSH命令。你需要做的就是這樣寫:

ssh -X "your_login" 
+12

作爲參考,這不是OP問題的解決方案。我曾在自己的回答中提出建議,然後在OP告訴我它沒有解決問題時將其刪除。該問題與此處給出的相同,並且還包含解決方案:http://stackoverflow.com/q/2801882/1399279。 – SethMMorton

+0

提醒一下,'ssh -X'有時會給你一些警告,例如'Warning:不可信的X11轉發設置失敗:未生成xauth密鑰數據',在這種情況下,你應該改用'ssh -Y'。 –

相關問題