python Bokeh 库的权限被拒绝(在 virtualenv 中)

Permission Denied with python Bokeh library (in virtualenv)

[Python, 木星, Ubuntu 16]

我有一个 python3.5 virtualenv,我安装了 bokeh。我可以导入,定义一个图表就好了:

p.xaxis.axis_label = 'petal len'
p.yaxis.axis_label = 'petal width'
p.circle(flowers['petal_length'], flowers['petal_width'], color=colors, fill_alpha=0.2, size=10)

但是当我调用 show(p) 时,我得到以下信息:

PermissionError                           Traceback (most recent call last)
<ipython-input-7-52ee71fc1db5> in <module>()
      2 p.yaxis.axis_label = 'petal width'
      3 p.circle(flowers['petal_length'], flowers['petal_width'], color=colors, fill_alpha=0.2, size=10)
----> 4 show(p)

/home/USERNAME/ve/ml/lib/python3.5/site-packages/bokeh/io.py in show(obj, browser, new, notebook_handle)
    298     if obj not in _state.document.roots:
    299         _state.document.add_root(obj)
--> 300     return _show_with_state(obj, _state, browser, new, notebook_handle=notebook_handle)
    301 
    302 

/home/USERNAME/ve/ml/lib/python3.5/site-packages/bokeh/io.py in _show_with_state(obj, state, browser, new, notebook_handle)
    316 
    317     if state.file or not shown:
--> 318         _show_file_with_state(obj, state, new, controller)
    319 
    320     return comms_handle

/home/USERNAME/ve/ml/lib/python3.5/site-packages/bokeh/io.py in _show_file_with_state(obj, state, new, controller)
    321 
    322 def _show_file_with_state(obj, state, new, controller):
--> 323     filename = save(obj, state=state)
    324     controller.open("file://" + filename, new=_new_param[new])
    325 

/home/USERNAME/ve/ml/lib/python3.5/site-packages/bokeh/io.py in save(obj, filename, resources, title, state, validate)
    380 
    381     filename, resources, title = _get_save_args(state, filename, resources, title)
--> 382     _save_helper(obj, filename, resources, title, validate)
    383     return os.path.abspath(filename)
    384 

/home/USERNAME/ve/ml/lib/python3.5/site-packages/bokeh/io.py in _save_helper(obj, filename, resources, title, validate)
    447         html = standalone_html_page_for_models(obj, resources, title)
    448 
--> 449         with io.open(filename, "w", encoding="utf-8") as f:
    450             f.write(decode_utf8(html))
    451 

PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.5/runpy.html'

我试过 chown -R 755 /usr/lib/python3.5 没用。 ~/virtualenv/lib/python3.5(奇怪地)主要是 777,但在全新安装时也是如此,所以我猜这是故意的。

始终建议使用 output_fileoutput_notebook 来明确说明应从何处显示输出。对于 Jupyter 笔记本中的内联图,output_notebook 实际上是 必需的 ,因为这是将必要的 BokehJS 库加载到笔记本中的命令。如果不指定其中任何一个,Bokeh 将尝试保存到 HTML 文件然后显示。在 0.12.5 之前,Bokeh 会尝试使用当前模块名称来推断位置,这在某些情况下可能会导致上述问题。在 0.12.5 之后,Bokeh 将使用 OS 提供的保证可写的临时文件位置。