第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當(dāng)顯示未定義時用matplotlib生成png

當(dāng)顯示未定義時用matplotlib生成png

哈士奇WWW 2019-06-18 16:15:58
當(dāng)顯示未定義時用matplotlib生成png我試圖在Python中使用networkx。當(dāng)我運行這個程序時,它會得到這個錯誤。有遺漏什么嗎?#!/usr/bin/env pythonimport networkx as nximport matplotlibimport matplotlib.pyplotimport matplotlib.pyplot as plt G=nx.Graph()G.add_node(1)G.add_nodes_from([2,3,4,5,6,7,8,9,10])#nx.draw_graphviz(G)#nx_write_dot(G, 'node.png')nx.draw(G) plt.savefig("/var/www/node.png")Traceback (most recent call last):   File "graph.py", line 13, in <module>     nx.draw(G)   File "/usr/lib/pymodules/python2.5/networkx/drawing/nx_pylab.py", line 124, in draw     cf=pylab.gcf()   File "/usr/lib/pymodules/python2.5/matplotlib/pyplot.py", line 276, in gcf    return figure()   File "/usr/lib/pymodules/python2.5/matplotlib/pyplot.py", line 254, in figure    **kwargs)   File "/usr/lib/pymodules/python2.5/matplotlib/backends/backend_tkagg.py", line 90, in new_figure_manager     window = Tk.Tk()   File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1650, in __init__     self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)_tkinter.TclError:      no display name and no $DISPLAY environment variable我現(xiàn)在遇到了一個不同的錯誤:#!/usr/bin/env pythonimport networkx as nximport matplotlibimport matplotlib.pyplotimport matplotlib.pyplot as plt matplotlib.use('Agg')G=nx.Graph()G.add_node(1)G.add_nodes_from([2,3,4,5,6,7,8,9,10])#nx.draw_graphviz(G)#nx_write_dot(G, 'node.png')nx. draw(G)plt.savefig("/var/www/node.png")/usr/lib/pymodules/python2.5/matplotlib/__init__.py:835: UserWarning:  This call to matplotlib.use() has no effect because the the backend has already been chosen;matplotlib.use() must be called *before* pylab, matplotlib.pyplot,or matplotlib. backends is imported for the first time.   if warn: warnings.warn(_use_error_msg)Traceback (most recent call last):   File "graph.py", line 15, in <module>     nx.draw(G)   File "/usr/lib/python2.5/site-packages/networkx-1.2.dev-py2.5.egg/networkx/drawing/nx_pylab.py", line 124, in draw     cf=pylab.gcf()
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 1212 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號