Ask Your Question

Run a notebook from console

asked 2020-05-09 04:59:39 -0500

Cyrille gravatar image

Certainly a stupid question but is it possible to run a notebook from console? And how ?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2020-05-09 08:57:37 -0500

slelievre gravatar image

updated 2020-05-09 08:59:31 -0500

edit flag offensive delete link more

answered 2020-05-09 05:17:01 -0500

Juanjo gravatar image

updated 2020-05-09 09:00:45 -0500

Assuming that the notebook is foo.ipynb, you can type:

$ sage -n jupyter foo.ipynb

Once you close the notebook, the Jupyter server remains active. To open a new notebook, you can type https://localhost:xxxx ( where xxxx usually is 8888) in your default browser and access the Jupyter landing page. If you want to finish working, you should stop manually the server.

EDIT (to answer @Cyrille's comment): You can do this:

  1. Open the notebook, say foo.ipynb, in Jupyter.
  2. Export the notebook as a Python script by choosing File > Download as > Python (.py). You get somewhere in your computer (probably in the Downloads folder)
  3. Rename to foo.sage
  4. In the console, use cd C:\path\to\folder to go to the folder where foo.sage is located
  5. Launch SageMath by typing sage
  6. Inside Sagemath, run foo.sage by typing load("foo.sage")
  7. Repeat the last three steps every time you want
edit flag offensive delete link more


Thanks for your answer but (I am under Windows10) I donot know how to type the path C:/toto/ C:\toto... Secondly my question was, and I recognize, it was not crystal clear :" could I run an ipynb without recourse to jupiter"

Cyrille gravatar imageCyrille ( 2020-05-09 06:27:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-05-09 04:59:39 -0500

Seen: 43 times

Last updated: May 09