无法正确安装和使用pythreejs

问题描述 投票:0回答:1

我按照official website上的说明安装了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'official repository,它没有向我显示页面中嵌入的可视化窗口。相反,它在单元格下面显示一个哈希:

UmVuZGVyZXIoY2FtZXJhPVBlcnNwZWN0aXZlQ2FtZXJhKGNoaWxkcmVuPShEaXJlY3Rpb25hbExpZ2h0KGNvbG9yPSd3aGl0ZScsIGludGVuc2l0eT0wLjUsIHBvc2l0aW9uPSgzLjAsIDUuMCzigKY=

我也尝试使用jupyter实验室和Python2,它的行为完全相同。

我想念什么?

系统:Ubuntu 18.04Jupyter Notebook版本:5.7.8

install jupyter pythreejs
1个回答
0
投票

在控制台中更仔细地查看jupyter的输出,我读到:

[W 18:55:45.544 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20200107185531 (127.0.0.1) 14.69ms referer=http://localhost:8889/notebooks/Untitled.ipynb?kernel_name=python3

跟随advice for this error我这样做:

jupyter nbextension enable --py widgtesextension

然后启动服务器:pythreejs正常工作!!

© www.soinside.com 2019 - 2024. All rights reserved.