更新到最新的開發版本,Matplotlib-1.4.x的。使用virtualenv安裝
$ pip install -e [email protected]:matplotlib/matplotlib.git
然後OP的命令可以在所有平臺上運行。還有一個新的embedded webagg example in the matplotlib master branch on GitHub適用於我所有的系統(Windows-7x64,Ubuntu-14.14和Xubuntu-14.14)。
使用OP的命令與Matplotlib-1.3.1,我得到的這取決於不同的結果在哪個平臺上我使用。在一臺機器(Ubuntu的14.14),我是能夠顯示數字,如果我用sudo
執行OP的命令:
$ sudo python
>>> import matplotlib
>>> matplotlib.use('webagg')
>>> import matplotlib.pyplot as plt
>>> plt.plot(range(10))
>>> plt.show()
這適用於的virtualenv和matplotlib的Ubuntu發行版本。
雖然的VMware Player虛擬機(Xubuntu上-14.14託管在Windows的7x64)對我是能夠顯示利用OP的命令圖中沒有sudo
。在第三臺(Windows-7x64)機器上,我仍然無法使用OP的命令獲取數字,無論是否具有管理員權限。我也將matplotlib.rcParams['webagg.port']
更改爲8080和8000,但這也沒有奏效。
在Ubuntu-14.14使用matplotlib從分佈的存儲庫安裝,您將看到下面的回溯:
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_webagg.py", line 381, in get
'matplotlib.png'), 'rb') as fd:
IOError: [Errno 2] No such file or directory: '/usr/lib/pymodules/python2.7/matplotlib/mpl-data/images/matplotlib.png'
它無關,爲什麼圖像不顯示;此錯誤只出現在其中mpl-data文件夾不在matplotlib.backends.backend_webagg
預期的位置,但實際上位於/usr/share/matplotlib/
的Linux機器上。具體來說,backend_webagg
正在尋找它用作web瀏覽器選項卡圖標的文件matplotlib.png
,實際上即使Tornado沒有找到該文件,它仍然會提供該頁面,但不幸的是它仍然會發出此錯誤。
如果您使用virtualenv,您將看不到favicon錯誤。
使用Matplotlib-1.3。1在Ubuntu-14.14和Windows-7x64機器上沒有sudo
我收到了@allisonmuller在上面評論中看到的相同的「圖1」鏈接問題。
您的代碼工作正常,我。該圖形在瀏覽器窗口中彈出。你有其他的錯誤嗎? –
我的建議是嘗試重新安裝Python和matplotlib。這通常會很難解決你的問題。 –
使用VirtualBox,我嘗試了Ubuntu 12.10(隨附Python 2.7.3)的全新安裝,然後安裝了NumPy,Matplotlib及其依賴項。但是,WebAgg瀏覽器窗口仍然只顯示「圖1」鏈接,沒有任何數字。點擊鏈接也沒有結果。 – alissonmuller