【问题标题】:Can't install and use properly pythreejs无法正确安装和使用pythreejs
【发布时间】:2020-01-07 19:06:00
【问题描述】:

我按照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 lab 和 Python2,它的行为完全相同。

我错过了什么?

系统:Ubuntu 18.04 Jupyter Notebook 版本:5.7.8

【问题讨论】:

    标签: installation jupyter pythreejs


    【解决方案1】:

    在控制台中更仔细地查看 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 工作!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-13
      • 2020-09-23
      • 2020-01-29
      • 2020-08-20
      • 2012-12-02
      • 2020-07-19
      相关资源
      最近更新 更多