NameError: name 'get_ipython' is not defined

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:

plt.show(block=True)

get_ipython is available only if the IPython module was imported that happens implicitly if you run ipython shell (or Jupyter notebook).

If not, the import will fail, but you can still import it explicitly with:

from IPython import get_ipython

You have to run your script with ipython:

$ ipython python/my_test_imagenet.py

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.