NameError: name 'get_ipython' is not defined

You have to run your script with ipython:

$ ipython python/

Then get_ipython will be already in global context.

Note: Importing it via from IPython import get_ipython in ordinary shell python will not work as you really need ipython running.

If your intention is to run converted .py file notebook then you should just comment out get_ipython() statements. The matlibplot output can't be shown inside console so you would have some work to do . Ideally, iPython shouldn't have generated these statements. You can use following to show plots: