germ
germ

Reputation: 1669

Running a Windows command line with arguments from Jupyter notebook

At the end of my notebook, I want to export an HTML version of it. So I use the jupyter nbconvert command line utility in a notebook cell:

!jupyter nbconvert '$nb_path' --output '$nfname'

where nb_path contains the path to the notebook file (.ipynb) and nfname is a name that ends in .html.

This works fine on a Mac, but fails in Windows 10. There I get as output:

"This application is used to convert..."

that is, the same output as if I run just jupyter nbconvert (without arguments) in a cmd prompt.

If I open a cmd prompt and manually type the above command (with the actual file names instead of the variable names), then everything executes just fine.

So it seems that the ! shortcut in jupyter notebook cell doesn't pass the arguments properly to the windows terminal. Is there a mechanism to do that, or do I have to resort to Popen?

Upvotes: 0

Views: 868

Answers (1)

labroid
labroid

Reputation: 463

Use double quotes:

!jupyter nbconvert "$nb_path" --output "$nfname"

works for me on Windows 10

Upvotes: 1

Related Questions