Running interactive command line code from Jupyter notebook

the !commandsyntax is an alternative syntax of the %system magic, which documentation can be found here.

As you guessed, it’s invoking os.system and as far as os.system works there is no simple way to know whether the process you will be running will need input from the user. Thus when using the notebook or any multi-process frontend you have no way to dynamically provide input to your the program you are running. (unlike a call to input in Python we can intercept).

As you explicitly show interest in installing packages from the notebook, I suggest reading the following from Jake Van Der Plas which is a summary of a recent discussion on the subject, and explain some of the complications of doing so. You can of course go with --yes option of conda, but it does not guarantee that installing with conda will always work.

Note also that !command is an IPython feature, not a Jupyter one.

Leave a Comment