matthias-k/ipython-journal

Error in journal.savefig()

tomwallis opened this issue · 2 comments

I get an error deep in journal.savefig(). This happens when I call the example in the readme as well. Perhaps because I am using Python 3.3? Error output below:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-1477a0803b8b> in <module>()
      2 # fig.fig.set_figwidth(8)
      3 # fig.fig.set_figheight(6)
----> 4 journal.savefig()

/Users/tomwallis/Dropbox/Python/ipython-journal/build/lib/ipythonjournal/journal.py in savefig()
     81 
     82 def savefig():
---> 83     get_journal().savefig()
     84 
     85 

/Users/tomwallis/Dropbox/Python/ipython-journal/build/lib/ipythonjournal/journal.py in savefig(self)
     30 
     31     def savefig(self):
---> 32         filename = self.get_filename(ext='.png')
     33         plt.savefig(filename, bbox_inches='tight')
     34         print('<img src="files/{0}" />'.format(filename))

/Users/tomwallis/Dropbox/Python/ipython-journal/build/lib/ipythonjournal/journal.py in get_filename(self, ext)
     21 
     22     def get_filename(self, ext=None):
---> 23         filename = getId()
     24         if ext is not None:
     25             if not ext.startswith('.'):

/Users/tomwallis/Dropbox/Python/ipython-journal/build/lib/ipythonjournal/journal.py in getId()
     12 
     13 def getId():
---> 14     return "%s-%s" % (datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'), hashlib.sha1("%s" % random.random()).hexdigest()[:8])
     15 
     16 

TypeError: Unicode-objects must be encoded before hashing

Hi Tom,

sorry for the late reply. This is definitely due to using python 3.3. The fix should be fairly trivial, I will implement it today.

Best,
Matthias

savefig should work with python3 now. I am going to implement some more tests for the other functions, too.