我正在尝试使用bokeh0.11.1(Python3.5,Windows7)中的DatePicker小部件。但我没有让它工作的运气。下面是一个不能工作的代码的最小示例:
from datetime import date
from bokeh.client import push_session
from bokeh.models import VBoxForm
from bokeh.io import curdoc
from bokeh.models.widgets import DatePicker
session = push_session(curdoc())
picker = DatePicker(title="Test",
min_date=date(2016, 1, 1),
max_date=date(2016, 1, 31),
value=date(2016, 1, 1))
curdoc().add_root(VBoxForm(children=[picker]))
session.show()此代码是在使用bokeh serve启动bokeh服务器后运行的。
我在服务器的控制台中得到以下错误:
ERROR:bokeh.server.protocol.server_handler:error handling message Message 'PATCH
-DOC' (revision 1): OSError(22, 'Invalid argument')
DEBUG:bokeh.server.protocol.server_handler: message header {'msgid': '158e1568-
ece3-49b7-8b60-70a3b44ed64b', 'msgtype': 'PATCH-DOC'} content {'events': [{'kind
': 'RootAdded', 'model': {'id': 'a7b1c3bf-0efe-4a89-bb18-f9fb7609c59c', 'type':
'VBoxForm'}}], 'references': [{'id': 'a7b1c3bf-0efe-4a89-bb18-f9fb7609c59c', 'at
tributes': {'children': [{'id': '2e4ecc9c-5869-4abf-aef6-412d6cef30bc', 'type':
'DatePicker'}]}, 'type': 'VBoxForm'}, {'id': '2e4ecc9c-5869-4abf-aef6-412d6cef30
bc', 'attributes': {'max_date': 1454198400000.0, 'title': 'Test', 'callback': No
ne, 'value': 1451606400000.0, 'min_date': 1451606400000.0}, 'type': 'DatePicker'
}]}
Traceback (most recent call last):
[...]
File "C:\Users\Macfli\AppData\Local\Continuum\Anaconda3\lib\site-packages\boke
h\core\properties.py", line 1523, in transform
value = datetime.date.fromtimestamp(value)
OSError: [Errno 22] Invalid argument基本上,调用datetime.date.fromtimestamp(value)得到了一个无效参数,我不知道它是从哪里来的。我尝试了DatePicker构造函数的不同输入类型,并调试到bokeh代码中,在将文档发送到服务器之前,所有对象都创建得很好。
我能找到的关于DatePicker的唯一资源是the bokeh reference page,但它并没有真正的帮助。有没有人有同样的问题?
发布于 2016-04-14 00:56:26
改为: datetime.datetime(2016,1,1,2,0)。不幸的是,当我点击一个日期时,选择器崩溃了。
https://stackoverflow.com/questions/36401184
复制相似问题