How to make Jupyter lab recognize a file as notebook that is not .ipynb? - jupyter-notebook

I added kernels for Julia and Haskell in Jupyter lab, however the filename extension for which is still ipynb, and I really like to distinguish them from IPython notebook.
I renamed them as *.ijlnb or *.ihsnb however Jupyter lab no longer recognizes them as notebooks but a plain text.
How to assosiate .ijlnb or .ihsnb file to Jupyter?

Related

Open jupyter notebook from .py in pycharm

I am using Pycharm 2021.2.3 pro.
Is it possible to open a .py file as a jupyter notebook from within pycharm?
In the classical jupyter notebook, it is possible to open a .py file as a notebook and work with it like with a classical .ipynb (adding markdown etc.).
This allows to work on the full notebook without worrying about cells ordering like with a classical python script. When the script is ready, it is then possible to switch to the notebook view with its nice presentation features.
we did this when creating dash apps, you make the .py file upload and refer to it by way of importing as we do with regular python libraries

Linking VS Code interactive window to running Jupyter notebook

Let's say that you have two windows open in VS Code, one is a Jupyter notebook, and the other is the Python interactive window. Both are running the same kernel. Is there a way to link these two windows, so when cells are run in the notebook, the interactive window will know about the resulting variables?
I'm aware that VS Code has a Python code format that can be linked to the interactive window, and that Jupyter notebooks can be converted into this format. Is it possible to directly link a Jupyter notebook to the interactive window without first doing this conversion?
With JupyterLab the is accomplished with the New Console for Notebook command.

Running Jupyter notebook (and generating plots) from the command line

I'm trying to use the terminal to run a jupyter notebook (kernel: Julia v1.6.2), which contains generated using Plots.jl, before uploading the notebook to github for viewing on nbviewer.com.
Following this question:
How to run an .ipynb Jupyter Notebook from terminal?
I have been using nbconvert as follows:
jupyter nbconvert --execute --to notebook --inplace
This runs the notebook (if you tweak the timeout limits), however, it does not display plots when using Plots.jl, even when I explicitly call display(plot()) at the end of a cell.
Does anyone have any idea how notebooks can be run remotely in such a manner that plots will be generated and displayed, particularly when using Julia?
I managed to generate Plots.jl plots by getting from IJulia the same configuration it uses to run notebooks (this is probably the most sure way when you have many Pyhtons etc.).
using Conda, IJulia
Conda.add("nbconvert") # I made sure nbconvert is installed
mycmd = IJulia.find_jupyter_subcommand("nbconvert")
append!(mycmd.exec, ["--ExecutePreprocessor.timeout=600","--to", "notebook" ,"--execute", "note1.ipynb"])
Now mycmd has exactly the same environment as seen by IJulia so we can do run(mycmd):
julia> run(mycmd)
[NbConvertApp] Converting notebook note1.ipynb to notebook
Starting kernel event loops.
[NbConvertApp] Writing 23722 bytes to note1.nbconvert.ipynb
The outcome got saved to note1.nbconvert.ipynb, I open it with nteract to show that graphs actually got generated:
Launch notebook with using IJulia and notebook() in the REPL

How can i edit jupyter notebook from terminal without opening web browser?

How can I edit my jupyter notebook in terminal.
I just don't like to open jupyter notebook in web browser.
I google out but every answer is related to how can we open notebook from terminal directly.
I'd suggest looking at Jupytext's ability to do command line conversions back-and-forth from the notebook json structure to a python script (or markdown). If you already have the backbone of a notebook (.ipynb) file, you can convert it to .py script using jupytext --to py notebook.ipynb. That makes a text file that is easy to edit in your favorite terminal based text editor. The json in the .ipynb files is not as easy to edit directly.
Then when you are done editing, you can convert the .py script form back to a notebook with something like jupytext --to notebook notebook.py. Optionally, you can even execute it without opening a browser by adding --execute. I have an example conversion-and-execution command in use here.

Does Jupyter Notebook have a file rename hook?

I've written a custom pre_save_hook that's similar to the one that the Jupyter Notebook docs provide. The one I've written adds metadata to a notebook when the notebook is saved. However, the pre_save_hook doesn't seem to get called when a notebook is renamed. Is there something similar to the pre_save_hook for renaming a notebook?

Resources