Blog
How to import a Jupyter notebook like a Python module

Life will be easier if you can import a Jupyter notebook as a Python module when you are working on another notebook. However, the command import [notebook name] simply ends up with ModuleNotFoundError since JupyterLab notebooks have a different format and extension from Python scripts. Technically you could export notebooks as executable scripts whenever you edit your codes, but that should be too cumbersome and error-prone. Solutions The simplest method The config file ~/.jupyter/jupyter_notebook_config.py allows you to have JupyterLab automatically export notebooks as Python scripts each time you make changes. By doing so, you can elimitate the step to manually export scripts. All you still have to do is to […]

Read more