python - 错误 : 'charmap' codec can't decode byte 0x9d in position 3696: character maps to <undefined> (Windows Command Line, Bokeh 程序)

标签 python utf-8 bokeh

我一直在尝试运行类似于Bokeh 中的gapminder 程序的东西。我相当确定我的绘图代码没有问题,所以我不会发布它,并且我大约 70% 确定我的绘图更新代码也很好。但是,当我运行时

bokeh serve --show myapp.py   

在我的 Windows 命令提示符中,我收到错误:“charmap”编解码器无法解码位置 3696 中的字节 0x9d:字符映射到 .我知道我的代码是用 utf-8 编码的,我如何确保 Windows 可以运行它?或者有没有更好的方法来设置 Bokeh 服务器,因为我计划在网站上实现它?

这是我的代码的 slider /动画部分:

def animate_update():
    patchnum = slider.value + 0.1
    if patchnum > testdata['gameVersion'][slidelength]:
        patchnum = testdata['gameVersion'][0]
    slider.value = patchnum


def slider_update():
    truepatch = slider.value
    label.text = str(truepatch)
    newdata = testdata[testdata['gameVersion'] == truepatch].to_dict
    source.data = newdata

slider = Slider(start=testdata['gameVersion'][0], end=testdata['gameVersion']    [slidelength], value=testdata['gameVersion'][0], step=0.1, title='Patch')
slider.on_change('value', lambda attr, old, new: slider_update)

callback_id = None

def animate():
    global callback_id
    if button.label == '► Play':
        button.label = '❚❚ Pause'
        callback_id = curdoc().add_periodic_callback(animate_update, 200)
    else:
        button.label = '► Play'
        curdoc().remove_periodic_callback(callback_id)

button = Button(label='► Play', width=60)
button.on_click(animate)

layout = layout([
    [plot],
    [slider, button],
], sizing_mode='scale_width')

curdoc().add_root(layout)
curdoc().title = 'Playrate, Banrate and Winrate by Patch'
output_file('champminder.html')
show(layout)

最佳答案

几周前,当我尝试在 Windows 环境中使用特殊字符(德语元音变音)时,我看到了同样的问题。

对我来说,解决方案是以编程方式运行服务器,如下例所示:

在我看来,“bokehserve ...”没有正确处理编码。

关于python - 错误 : 'charmap' codec can't decode byte 0x9d in position 3696: character maps to <undefined> (Windows Command Line, Bokeh 程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51803887/

相关文章:

javascript - selenium driver.execute_script 中的 Python var

python - 将单词合并成一行

utf-8 - Windows 7 powershell 下的 mysqldump 将我所有的 utf-8 字符串转换为 latin1 或类似的东西

c++ - UTF-8、sprintf、strlen 等

jupyter-notebook - Bokeh 0.12.10 不在 GMapPlot 上渲染段

python - 如何在 bokeh python 中捕获下拉小部件的值?

python - 如何从 python 中传输许多 bash 命令?

python - `for` 循环如何在字典上具体工作

perl - 如何让 Perl 检测错误的 UTF-8 序列?

Python Bokeh : Multiple color segments on same line