VSCode and Jupyter notebook – changes in python script code dont update

Question:

When I write a code in the editor in VScode and then I try to import this code into jupyter notebook, the alterations I made in the code are do not update – the code that runs in jupyter notebook is the code that is open when I initialize VScode.

To update the code I need to restart VScode, open jupyter notebook, and import the code with the alterations made before restarting VScode. I set the path to the folder, and I using the same virtual environment. Is there anyway to fix this?

my screen

Asked By: Atilio

||

Answers:

You could download script file from jupyter as "py" file and run it on other editors most jupyter support that for example in anaconda jupyter jupyter anaconda

and google colab support this too
but a notebook run only with program support python notebook.

Answered By: omar

Try the autoreload magic method.
Above the import statement put this.

%load_ext autoreload
%autoreload 2

Note that %autoreload 2 means that all modules will be reimported, if you want to specify which ones to reload then use %autoreload 1 and import using %aimport instead of import

Answered By: RustyPython