NameError: name 'get_ipython' is not defined

前端 未结 3 589
终归单人心
终归单人心 2020-12-13 08:42

I am working on Caffe framework and using PyCaffe interface. I am using a Python script obtained from converting the IPython Notebook 00-classification.ipynb

相关标签:
3条回答
  • 2020-12-13 09:15

    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)
    
    0 讨论(0)
  • 2020-12-13 09:19

    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.

    0 讨论(0)
  • 2020-12-13 09:28

    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
    
    0 讨论(0)
提交回复
热议问题