Linking VS Code interactive window to running Jupyter notebook - 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.

Related

Unable to set the kernel ("Not specified") for a jupyter notebook in Pycharm

As seen in the screenshot the kernel is "Not specified" and can not set since the dropdown is disabled. Can this be remedied?
The Project interpreter is python3 and otherwise for other file types the project works fine
I've run into the same issue of PyCharm not allowing me to select a Jupyter kernel other than the one that is saved to the notebook (the drop-down menu is either grayed-out as in your picture, or disappears altogether). This condition appears to occur when the kernel that was active when the notebook was saved is not available in the current environment. The only workaround I've found for this situation is:
Start a Jupyter notebook server using the same Python environment as you are using in PyCharm
From the Jupyter server web page, open the notebook
From the Kernel menu, select Change kernel, and then select the desired kernel
Save the notebook, then close/halt it
Re-open the notebook in PyCharm. It should then be able to execute with the kernel that was chosen in Step 3 above.

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

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

Run A Specific Jupyter Notebook On Start

I would like to setup a system such that it not only runs jupyter notebook on start, but it also starts executing a specific notebook on that jupyter server (running all cells in sequence).
Is this possible? I specifically want to be able to access the notebook web interface and inspect/stop/etc the running notebook at any point.
I know nbconvert can execute a notebook, but it seems to run independently of any existing jupyter servers?
Maybe there is some API I can access so that I can write a shell script to run jupyter notebook and then use the API to open and run a notebook?

Jupyter Notebook SPSS integration

To run statistical tests on my data, I use SPSS and call it from a Jupyter Notebook. The integration works fine. I wondered, if there is a better way to display the results in a jupyter notebook. The tables seem to be messed up and figures wont show. Is it possible to output in a SPSS window from a Jupyter Notebook?
You can use the SPSS Model Visualizations for Jupyter [1], but if that is what you are already doing, then open and issue on the project? How are you calling SPSS from your Notebook?
[1] https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/spss-visualization.html?linkInPage=true

Resources