Issue
I recently started experiencing a strange problem with pyplot in my jupyter notebook. when trying to pyplot.pause()
, I get a name error in the actual matplotlib package.
This name error does not occur in the exact same code executed as a .py
file rather than an .ipynb
. Everything else executes the same between the .py
and .ipynb
, and they both use the same virtualenvironment and packages.
Error:
---------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-9-11e7508f518d> in <module>()
32 plt.title('Epoch: {0}, loss: {1:.4}'.format(epoch, loss_history[epoch-1]))
33 plt.show()
---> 34 plt.pause(0.001)
35 #display.display(plt.gcf())
36 #display.display(plt.show())
/home/user/.pyenv/versions/2.7.14/envs/P2714/lib/python2.7/site-packages/matplotlib/pyplot.pyc in pause(interval)
292 canvas.start_event_loop(interval)
293 else:
--> 294 time.sleep(interval)
295
296
NameError: global name 'time' is not defined
Solution
There was a bug report about this issue reported here. The issue is a missing import time
statement in pyplot.py.
A pull request solving this issue has already been merged into the master branch and should be included in version 2.1.1.
I can confirm that by using pyplot.py from the matplotlib master branch this problem does not appear for me anymore.
Answered By - jdamp
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.