我按照官方网站上的说明安装了pythreejs
pip3 install pythreejs
jupyter nbextension install --user --py pythreejs
jupyter nbextension enable --user --py pythreejs
查看 的输出jupyter nbextension list
,一切看起来都很好:
Known nbextensions:
config dir: /home/gael/.jupyter/nbconfig
notebook section
jupyter-threejs/extension enabled
- Validating: OK
但是当我启动服务器(jupyter notebook
)时,创建一个新的(Python3)笔记本,并尝试运行示例代码
from pythreejs import *
import numpy as np
from IPython.display import display
from ipywidgets import HTML, Text, Output, VBox
from traitlets import link, dlink
ball = Mesh(geometry=SphereGeometry(radius=1, widthSegments=32, heightSegments=24),
material=MeshLambertMaterial(color='red'),
position=[2, 1, 0])
c = PerspectiveCamera(position=[0, 5, 5], up=[0, 1, 0],
children=[DirectionalLight(color='white', position=[3, 5, 1], intensity=0.5)])
scene = Scene(children=[ball, c, AmbientLight(color='#777777')])
renderer = Renderer(camera=c,
scene=scene,
controls=[OrbitControls(controlling=c)])
display(renderer)
来自 pythreejs 的官方存储库,它没有显示嵌入在页面中的可视化窗口。相反,它在单元格下方显示一个哈希:
UmVuZGVyZXIoY2FtZXJhPVBlcnNwZWN0aXZlQ2FtZXJhKGNoaWxkcmVuPShEaXJlY3Rpb25hbExpZ2h0KGNvbG9yPSd3aGl0ZScsIGludGVuc2l0eT0wLjUsIHBvc2l0aW9uPSgzLjAsIDUuMCzigKY=
我还尝试了 jupyter lab 和 Python2,它的行为完全相同。
我错过了什么?
系统:Ubuntu 18.04 Jupyter Notebook 版本:5.7.8