I am using an online jupyter notebook that is somehow configured to read all .py files as jupyter notebook files:
I am a big fan of this setup and would like to use it everywhere. On my own jupyter installation however, .py files are just interpreted as test files and are not by default loaded into jupyter cells. How can I achieve the same configuration for my jupyter notebook?
load python file in jupyter notebook A text file can be loaded in a notebook cell with the magic command %load. the content of filename.py will be loaded in the next cell. You can edit and execute it as usual.
What you're looking for is jupytext. You just need to install it into python env from which you're running your jupyter notebooks:
pip install jupytext --upgrade
And you get this:
That's not exactly what you asked, but you can achieve something close to that by using the magic %load FILE.py
in a new jupyter notebook.
%load FILE.py
will copy the contents of FILE.py
in the current cell upon executing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With