Hello Jupyter Notebook

Installing jupyter

My system has Python 3.7.4 installed under Windows 10. I followed the directions for Installing Jupyter Notebook via command line:

  • pip install jupyter

Then running via command line:

  • jupyter notebook

Jupyter Notebook then lauched successfully. Next: Running the Notebook.

Running the notebook

I created this HelloJupyterNotebook page and then loaded the x3d package into Pythonas follows.

Loading x3d package

In [3]:
import x3d
x3d package loaded, have fun with X3D Graphics!

Since the x3d.py package is experimental, successful loading is confirmed by the message above.

Creating an X3D model

The following model fragment demonstrates an X3D model running in jupyter notebook. Note that each of the X3D nodes and statements are namespaced with the prefix x3d. Also note that field names are not prefixed.

In [26]:
import x3d

newModel = x3d.X3D(
    head=x3d.head(children=[
        x3d.component(name='Core',level=2),
        x3d.unit(),
        x3d.meta(name='title',content='HelloJupyterNotebook.py')]),
    Scene=x3d.Scene(children=[
        x3d.WorldInfo(),
        x3d.Group()]))

Showing an error

Here is an intentional error forcing a Python TypeError, thus showing that the notebook is active.

In [13]:
newModel + 2;
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-eaf770075e07> in <module>
----> 1 newModel + 2;

TypeError: unsupported operand type(s) for +: 'X3D' and 'int'
In [ ]: