我可以將DataTable顯示在Jupyter Notebook中,沒有任何問題。但我一直無法通過服務器(curdoc()。add_root())來顯示它。當我嘗試訪問它時,我不會在服務器窗口中看到任何錯誤,並且只是瀏覽器上的空白頁面。我只是看到以下內容:如何讓散景服務器顯示數據表
2017-04-23 16:07:51,188 Starting Bokeh server on port 5006 with applications at paths ['/myapp']
2017-04-23 16:07:51,188 Starting Bokeh server with process id: 7484
2017-04-23 16:07:55,365 200 GET /myapp (172.17.13.2) 188.14ms
2017-04-23 16:07:55,887 WebSocket connection opened
2017-04-23 16:07:55,888 ServerConnection created
下面是服務器正在運行什麼時候在筆記本上它與所需的通話更換,以顯示它(output_notebook(),顯示(佈局)):
import pandas as pd
from bokeh.plotting import Figure
from bokeh.models import ColumnDataSource, TextInput, Button, Panel, Tabs, Label, DataTable, TableColumn
from bokeh.layouts import Row, Column, widgetbox
from bokeh.io import curdoc, show, output_notebook, gridplot
from sqlalchemy import create_engine
engine = create_engine('postgresql+psycopg2://username:[email protected]:5432/dbname')
def main():
layout = gridplot([[retreive_descriptions()]])
curdoc().add_root(layout)
def retreive_descriptions():
df = pd.read_sql(sql='SELECT description from public."Description_Categories" WHERE category=\'Unknown\'', con=engine)
cds = ColumnDataSource(df)
columns = [TableColumn(field='description', title='Description'),TableColumn(field='category', title='Category')]
cat_data = DataTable(source=cds, columns=columns, editable=True)
return cat_data
我使用Python 3.4.2和Bokeh Server 0.12.5版。我相當新,所以任何幫助表示讚賞,爲什麼它可能不顯示。
還有我能目前加載了背景虛化服務器上正常的數字,沒有任何問題。只是無法顯示DataTable/gridplot。 – Aklys