You can call a magic command in Jupyter from a script as follows:
ipython = get_ipython()
mgc = ipython.run_line_magic
mgc(magic_name = "my_magic_command", line="line_to_call")
But if I try to do this with the HTML magic command:
mgc(magic_name = "%%html", line="<iframe src='my_url' width='100%' height='400'></iframe>")
I get the following error:
UsageError: Line magic function `%%%html` not found.
Makes me think I should remove one of the %:
mgc(magic_name = "%html", line="<iframe src='my_url' width='100%' height='400'>")
UsageError: Line magic function `%%html` not found.
...or remove both %:
mgc(magic_name = "html", line="<iframe src='my_url' width='100%' height='400'>")
UsageError: Line magic function `%html` not found (But cell magic `%%html` exists, did you mean that instead?).
This might have something to do with the order of imports, but I cannot seem to resolve the issue.