I'm using a Jupyter notebook as a tutorial for a command-line tool. However, I noticed that regardless of whether I use a shell command (!) or line magic (%), an error does not cause the cell to fail, and the execution simply continues. For example:
!pip install foo
%pip install foo
Is there any way to cause these errors to be fatal instead of continuing on to the next cell to execute?
%pip installor you are risking installations that occur where you don't expect. Or arguably worse, contributing to encouraging use by others of approaches that can lead to problems.%pip installhas been around since 2019 and even works in JupyterLite. Even Google Colab supports it now. .... Looking past that... the idea would be to add next atryclause where you tryimport foo.launch binderbadge. When the session comes up, you can try to make a new notebook and select the 'Bash' kernel as an option. (It seems to work intermittently right now. They are fixing it actively.)