iA


Inkscape and textext: Deprecation Warning

by Pascal Schulthess. Average Reading Time: about a minute.

I just came across the following error of textext in Inkscape.

~/.inkscape/extensions/textext.py:55: DeprecationWarning: 
the md5 module is deprecated; use hashlib instead
import os, sys, tempfile, traceback, glob, re, md5, copy

This error arises for textext 0.4.4., Inkscape 0.46 and Python 2.6.2. Fortunately I found a solution at bitbucket. But since I had some problems understanding how to change the python file, I will help you out with a detailed how-to.

Open the textext.py file mentioned in the error message with an editor of your choice. Now change the the lines

54
55
56
import inkex
import os, sys, tempfile, traceback, glob, re, md5, copy
from lxml import etree

into

54
55
56
57
import inkex
import os, sys, tempfile, traceback, glob, re, copy
import hashlib
from lxml import etree

Furthermore change

868
869
870
871
872
873
874
875
876
877
878
    def __init__(self, document):
        PdfConverterBase.__init__(self, document)
        self.hash = None
 
    def convert(self, *a, **kw):
        # compute hash for generating unique ids for sub-elements
        self.hash = md5.new('%s%s' % (a, kw)).hexdigest()[:8]
        return PdfConverterBase.convert(self, *a, **kw)
 
    def pdf_to_svg(self):
        exec_command(['pdf2svg', self.tmp('pdf'), self.tmp('svg'), '1'])

into

868
869
870
871
872
873
874
875
876
877
878
879
880
881
    def __init__(self, document):
        PdfConverterBase.__init__(self, document)
        self.hash = None
        USE_GTK = False
 
    def convert(self, *a, **kw):
        # compute hash for generating unique ids for sub-elements
        m = hashlib.md5()
        m.update('%s%s' % (a, kw))
        self.hash = m.hexdigest()[:8]
        return PdfConverterBase.convert(self, *a, **kw)
 
    def pdf_to_svg(self):
        exec_command(['pdf2svg', self.tmp('pdf'), self.tmp('svg'), '1'])

That’s it. Restart Inkscape and you’re done.

Happy TeXing

14 comments on ‘Inkscape and textext: Deprecation Warning’

  1. K says:

    Thanks! Just what I needed. :)

  2. Maximilian says:

    awsome! you made my day

  3. Maximilian says:

    btw, just saw that we are in the same field (academically).

    Grüße aus Darmstadt !

  4. Tuxfield says:

    Thanks a lot. It has cured my lasting headache.

  5. Ethan says:

    Thanks bud, this worked bootifully!

  6. David says:

    Thanks! Very helpful.

  7. Greg says:

    Awesome. Thanks a million!

  8. Mr. Drive says:

    Awesome!

    I got the error you are describing after fixing the “The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension” with the instructions given in http://caih.org/open-source-software/fixing-inkscape-in-mac-os-x/

    This solution works perfectly in Snow Leopard 10.6.3.

    Thanks for sharing your wisdom!

  9. Waluyo Adi Siswanto says:

    I found this textext fixing problem, at it worked.
    I spread to others too…

    Thanks and Regards
    WAS

  10. anon says:

    whoa! thanks a lot. this is why I love open source software :)

  11. Mario says:

    Many thanks, you saved me.

  12. [...] you need to update your textext files,  thanks to Pascal Schulthess for the [...]

  13. gregB says:

    Doesn’t seam to work for Windows 7. When editing with Jedit I get a java.io.FileNotFoundException even after enabling all privileges for texttex.py,texttext.inx, and C:\Program Files (x86)\Inkscape\share\extensions.

  14. Jaap says:

    Thanks a lot man!!

Leave a Reply