Search code examples
jupyterbookmyst

Running JupyterBook written in MyST markdown locally using Thebe


I am a new user of MyST and JupyterBook and am loving it so far. But I am struggling to get executable books locally using Thebe. I tried going through the documentation but have not been able to get it to work.

I want to have executable content on the web page version of my jupyterbooks. All while working locally and not have pushed anything onto github.

Running Jupyter-Book v1.0.3

Currently I have the following files: myst.yml

version: 1
project:
  title: Neural Geometry
  date: 2025/01/21
  authors:
    - name: Atharva Aalok
      email: atharvaaalok@gmail.com
      corresponding: true
      affiliations: Stanford University
      twitter: atharvaaalok
      github: atharvaaalok
  toc:
    - file: file1.ipynb
    - file: file2.ipynb
    - file: file3.ipynb
site:
  template: book-theme
  title: Neural Geometry

I also have the mentioned file[i].ipynb files.

I launch the local web version by running in the command line:

$ myst

Then I select 'yes' in the command line after which I get the link to webpage `http://localhost:3000/neural-geometry' I then just type this in chrome to get view the book.

How do I change my code to have thebe working? I want to be able to run my python code cells and have my ipywidgets working on the web page of the book.

Note: I have tried reading the docs but am not understanding what exactly to write in the myst.yml file. The examples have _config.yml and _toc.yml. Also tried other stuff like first running a local jupyter server and using it but could not get things working.

Looking for a clear and step-by-step procedure that I can follow to get Thebe working.


Solution

  • I tried stuff from https://mystmd.org/guide/integrating-jupyter and it worked!

    My new myst.yml:

    version: 1
    project:
      title: Neural Geometry
      date: 2025/01/21
      jupyter:
        server:
          url: http://localhost:8888/
          token: abcd
      github: some_link
      authors:
        - name: Atharva Aalok
          email: atharvaaalok@gmail.com
          corresponding: true
          affiliations: Stanford University
          twitter: atharvaaalok
          github: atharvaaalok
      toc:
        - file: file1.ipynb
        - file: file2.ipynb
        - file: file3.ipynb
    site:
      template: book-theme
      title: Neural Geometry
      # options:
      #   favicon: favicon.ico
      #   logo: site_logo.png
    

    Then I start a local jupyter kernel using:

    jupyter-lab --NotebookApp.token=abcd --NotebookApp.allow_origin='http://localhost:3000'
    

    Then I build the project:

    myst build --all
    

    Then I start the local web page:

    myst start
    

    Now when I open the jupyterbook on the local host I am able to execute the cells!