Home > Explanations, Tips > Fixing textext on Inkscape 0.48

Fixing textext on Inkscape 0.48

November 13, 2010 Leave a comment Go to comments

I encounter one problem today. My textext didn’t work on Inkscape 0.48, I get the error

textext.py:55: DeprecationWarning: the md5 module is deprecated; use hashlib instead import os, sys, tempfile, traceback, glob, re, md5, copy
Traceback (most recent call last): File "textext.py", line 306, in <module>
raise RuntimeError("Neither pygtk nor Tkinter is available!")
RuntimeError: Neither pygtk nor Tkinter is available!

The error is due to a module depreciated on the python version used on Inkscape, and that Textext uses. However, it was pretty easy to solve.

  • First you need to download the python packages that are missing, thanks to David Gleich whom packed everything together, avoiding us the trouble of download them and put the pieces together.
  • Unzip them C:\Program Files\Inkscape\python\Lib\site-packages

Then you need to update your textext files,  thanks to Pascal Schulthess for the solution.

  • Go to C:\Program Files\Inkscape\share\extensions, and open textext.py file
  • Now replace
    import inkex
    import os, sys, tempfile, traceback, glob, re, md5, copy
    from lxml import etree
    

    and replace it for

    import inkex
    import os, sys, tempfile, traceback, glob, re, copy
    import hashlib
    from lxml import etree
    
  • And replace this
        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'])
    

    for

        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'])
    

Restart Inkscape and that would do the work. :mrgreen:

  1. Tester
    February 2, 2011 at 2:31 am | #1

    Hi,

    I have tried your solution and it minimized the errors. Nevertheless it says now:

    File “textext.py”, line 870

    def __init__(self, document):

    ^

    IndentationError: unindent does not match any outer indentation level

    Do you have any suggestions on what might be wrong? The line 870 is line 868 in your code.

    Greetings

  2. Max
    February 4, 2011 at 9:41 am | #2

    Python is very picky about indenting. make sure that in each codeblock you have the same indentation. Use spaces as opposed to tabs. Compare ou inserted code to the other functions and adjust the indentation accordingly.

  3. Sylvia
    February 20, 2011 at 12:19 pm | #3

    So, having followed these instructions I can get rid of the first complaint re: hashlib. But I’m still getting:

    File “textext.py”, line 307, in

    raise RuntimeError(“Neither pygtk nor Tkinter is available!”)

    RuntimeError: Neither pygtk nor Tkinter is available!

    Any advice?

    • February 22, 2011 at 10:43 am | #4

      Probably it is because the python in Inkscape is not updated, try to to replace the files with the download files I explain in the post.

  4. Sylvia
    February 23, 2011 at 7:27 am | #5

    Cheers, it’s fixed now. I forgot to put the files where I needed them…

  5. Sungkwang
    March 22, 2011 at 12:44 pm | #6

    Thank you for good information. TexText works now.

  6. asmwarrior
    April 9, 2011 at 11:56 am | #7

    thanks, now latex works fine under inkscape 0.48 (I use portable inkscape from http://portableapps.com/)

    Before doing the modification, these packages should be install on the system:
    1,install Miktex, then the pdflatex.exe should be in the PATH
    2,install gs902w32.exe, download from http://code.google.com/p/ghostscript/, gswin32.exe should in PATH
    3,install pstoeditsetup350.exe, and pstoedit.exe should in PATH
    4,install textext-0.4.4.exe
    5,do the modifications as you mentioned.

    Then, every thing works fine. thanks.

  7. Michele
    April 13, 2011 at 9:37 pm | #8

    I did all the procedure you described but i have this error:
    textext.py:227: GtkWarning: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)’ failed
    txt.get_buffer().set_text(err_msg)

    Do you know how can i solve it?

    Many thanks in advance

    Michele

  8. Imane
    April 15, 2011 at 2:37 am | #9

    Many Many thanks! that help me a lot!

  9. LEON
    April 30, 2011 at 7:09 pm | #10

    It is very interesting. But I still don’t fix this problem. Could you describe your install in details. I installed Python 2.5.4, pstoedit and textext extension. Then I did what you said in your post. But the problem still exists!

    • May 2, 2011 at 10:53 am | #11

      Did you use the packages in the links?
      If you use those, there is no need to install other things. Everything comes in those packages.
      If you did, the other thing that comes to my mind is that previous installation are giving problem. Try to check which python inkscape is looking for.

  10. Prasad
    August 15, 2011 at 12:44 am | #12

    Hai i have followed the procedure but i am getting the following error

    Traceback (most recent call last):
    File “textext.py”, line 211, in cb_ok
    self.callback(self.text, self.preamble_file, self.scale_factor)
    File “textext.py”, line 370, in
    converter_cls, old_node))
    File “textext.py”, line 388, in do_convert
    new_node = converter.convert(text, preamble_file, scale_factor)
    File “textext.py”, line 756, in convert
    new_node = self.svg_to_group()
    File “textext.py”, line 778, in svg_to_group
    tree = etree.parse(self.tmp(‘svg’))
    File “lxml.etree.pyx”, line 2692, in lxml.etree.parse (src/lxml/lxml.etree.c:49594)
    File “parser.pxi”, line 1500, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:71364)
    File “parser.pxi”, line 1529, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:71647)
    File “parser.pxi”, line 1429, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:70742)
    File “parser.pxi”, line 975, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:67740)
    File “parser.pxi”, line 539, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:63824)
    File “parser.pxi”, line 625, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:64745)
    File “parser.pxi”, line 565, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:64088)
    XMLSyntaxError: Document is empty, line 1, column 1

    could you please help in this matter

    • phero
      October 6, 2011 at 4:29 pm | #13

      Hi, I had a similar problem, and it turned out that my 32-bit pstoedit refused to work with 64-bit version of ghostscript. Installing 64-bit version of pstoedit fixed the problem for me, maybe you should check if your tools are all 32-bit / 64-bit.

      • Prasad
        October 10, 2011 at 6:14 pm | #14

        Thank you for the reply. It worked for me

      • Christoph
        November 17, 2011 at 9:51 pm | #15

        I can confirm that this fixes the error mentioned.

  11. Ye Yuan
    August 30, 2011 at 9:46 pm | #16

    Hi,

    I follow exactly as it said. And I was extremely careful about the indent and space.
    But I still got this error,

    File “textext.py”, line 872

    USE_GTK = False

    ^

    IndentationError: unexpected indent

    Could you please help in this manner

  12. Payton
    September 20, 2011 at 12:29 am | #18

    Awesome post. Solved my problem in 5 minutes. Gracias

    • November 18, 2011 at 5:12 pm | #19

      De nada…
      I’m glad it helps… :mrgreen:

  13. Myungsunn Ryu
    October 3, 2011 at 7:49 pm | #20

    Thanks to all the great posts I got to the point of entering some TeX inputs.
    But when I enser something like $a$ or anything normal TeX input and press “OK” I get this stream of error messages:

    Traceback (most recent call last):
    File “textext.py”, line 211, in cb_ok
    self.callback(self.text, self.preamble_file, self.scale_factor)
    File “textext.py”, line 370, in
    converter_cls, old_node))
    File “textext.py”, line 390, in do_convert
    converter.finish()
    File “textext.py”, line 680, in finish
    self.remove_temp_files()
    File “textext.py”, line 737, in remove_temp_files
    self.try_remove(self.tmp_path)
    File “textext.py”, line 744, in try_remove
    os.rmdir(filename)
    WindowsError: [Error 145] : ‘c:\\docume~1\\mingshey\\locals~1\\temp\\tmpw1uq17′

  14. Myungsunn Ryu
    October 3, 2011 at 9:08 pm | #21

    When I rummage the directory ‘c:\\docume~1\\mingshey\\locals~1\\temp\\tmpw1uq17′ and open the texput.log file which reports the error:

    This is pdfTeX, Version 3.1415926-2.3-1.40.12 (Web2C 2011) (format=pdflatex 2011.10.3) 3 OCT 2011 21:04
    entering extended mode
    restricted \write18 enabled.
    %&-line parsing enabled.
    **c:\docume~1\mingshey\locals~1\temp\tmpawgi2e\tmp.tex -interaction=nonstopmode
    -halt-on-error

    ! Emergency stop.
    c:\docume
    ~1\mingshey\locals~1\temp\tmpawgi2e\tmp.tex -interaction=nonsto…
    End of file on the terminal!

    Here is how much of TeX’s memory you used:
    1 string out of 493633
    83 string characters out of 3145073
    49245 words of memory out of 3000000
    3405 multiletter control sequences out of 15000+200000
    3640 words of font info for 14 fonts, out of 3000000 for 9000
    831 hyphenation exceptions out of 8191
    0i,0n,0p,1b,6s stack positions out of 5000i,500n,10000p,200000b,50000s
    ! ==> Fatal error occurred, no output PDF file produced!

  15. Myungsunn Ryu
    October 3, 2011 at 9:51 pm | #22

    I overlooked the issue with TeX Live. I was working with TeXLive and now I see I have to download MikTeX.

    Thanks for all the help!

  16. duckfunny
    October 12, 2011 at 3:34 pm | #23

    Hey,

    First of all thanks a lot. It solved a few errors, but now there are new ones:

    Traceback (most recent call last):

    File “textext.py”, line 937, in

    e.affect()

    File “C:\Program Files (x86)\Inkscape\share\extensions\inkex.py”, line 215, in affect

    self.effect()

    File “textext.py”, line 349, in effect

    % ‘;\n’.join(converter_errors))

    RuntimeError: No Latex -> SVG converter available:

    Pdf2Svg: Command pdf2svg failed: [Error 2] Das System kann die angegebene Datei nicht finden;

    PstoeditPlotSvg: Command pstoedit -help failed: [Error 2] Das System kann die angegebene Datei nicht finden;

    SkConvert: Command pstoedit failed: [Error 2] Das System kann die angegebene Datei nicht finden

    Sorry for the german parts. There is just standing, that the system cannot find the files. I tried to fix this problem without success. Maybe somebody can help me.

    Greetz, duckfunny

    • Tariq
      November 22, 2011 at 7:34 am | #24

      Hello Duck funny. I am exactly getting the same errors as yours:

      Traceback (most recent call last):

      File “textext.py”, line 936, in

      e.affect()

      File “C:\Program Files (x86)\Inkscape\share\extensions\inkex.py”, line 215, in affect

      self.effect()

      File “textext.py”, line 349, in effect

      % ‘;\n’.join(converter_errors))

      RuntimeError: No Latex -> SVG converter available:

      Pdf2Svg: Command pdf2svg failed: [Error 2] The system cannot find the file specified;

      PstoeditPlotSvg: Command pstoedit -help failed: [Error 2] The system cannot find the file specified;

      SkConvert: Command pstoedit failed: [Error 2] The system cannot find the file specified

      Kindly help me with the solution.

      • Caitlin
        December 8, 2011 at 3:29 am | #25

        I fixed this by added the pstoedit path to the path system variable.

  17. duckfunny
    October 12, 2011 at 5:52 pm | #26

    Ok, now the latex-formula is working somehow, there are still errors but i get my latextext. I followed this [url=http://en.wikiversity.org/wiki/User:Egm6341.s10.team3.heejun/Inkscape]this[\url] to fix the problem above. But now there is the next problem. After the dialog box for textext following error happens:

    textext.py:177: GtkWarning: Attempting to store changes into `C:\Programme\HOME\.recently-used.xbel’, but failed: Datei »C:\Programme\HOME\.recently-used.xbel.95WE3V« konnte nicht angelegt werden: Permission denied

    gtk.main()

    textext.py:177: GtkWarning: Attempting to set the permissions of `C:\Programme\HOME\.recently-used.xbel’, but failed: Permission denied

    gtk.main()

    Anyone an idea what to do?

    Greetz, duckfunny

    • October 12, 2011 at 6:05 pm | #27

      Hi, that looks like you have some issues with your folder permissions. Try to see if the “Read Only” option is marked. Then, uncheck it.

  18. duckfunny
    October 12, 2011 at 6:25 pm | #28

    Hey, thank you for your quick answer! Thats solved the errors by Latex-Formula. This works now fine. TexText says me now: “Error when examining the file C:\Programme\HOME with fstat(): No such file or directory”. When I ignore this message and use the textext dialog box to create latex signs it seems to be working but nothing appears. greetz

  19. Eph
    November 10, 2011 at 9:39 pm | #29

    Thank you very much for this post, it solved my issues within minutes.

    Since the original author does not seem to maintain textext any more, would it be interesting to take textext and your fix to start a branch?

  20. Inkscape_texText_Linux
    November 17, 2011 at 6:40 am | #30

    How to configure texText for inkscape 0.48 version on Linux PC?

    • November 18, 2011 at 5:16 pm | #31

      Hi, I haven’t try to use this fix in a Linux box. But, the issues are related to python. So you may start looking in there.

      Try to replace the code, as explained. And then pray that your version of python works. I’m not sure if Inkscape uses the python installed in Linux or it uses its own, like Windows. You should try to change it so it includes the latest versions.

      Good luck in your endeavor.

  21. zymurge
    December 9, 2011 at 11:23 am | #32

    This immediately fixed my problem, thank you so much!!

  22. .:Pi_Man:.
    December 16, 2011 at 9:17 pm | #33

    Thanks for the instructions!

    It seems to have solved most of the problems only now I get an error from windows regarding pstoedit, “The application was unable to start correctly (0xc000007b)” consequently inkscape returns an IO error, presumably as it’s looking for something that pstoedit should have created.

    Traceback (most recent call last):

    File “eqtexsvg.py”, line 156, in

    e.affect()

    File “C:\Program Files (x86)\Inkscape\share\extensions\inkex.py”, line 215, in affect

    self.effect()

    File “eqtexsvg.py”, line 150, in effect

    svg_open(self, svg_file)

    File “eqtexsvg.py”, line 81, in svg_open

    doc = inkex.etree.parse(filename)

    File “lxml.etree.pyx”, line 2692, in lxml.etree.parse (src/lxml/lxml.etree.c:49594)

    File “parser.pxi”, line 1500, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:71364)

    File “parser.pxi”, line 1529, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:71647)

    File “parser.pxi”, line 1429, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:70742)

    File “parser.pxi”, line 975, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:67740)

    File “parser.pxi”, line 539, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:63824)

    File “parser.pxi”, line 625, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:64745)

    File “parser.pxi”, line 563, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:64060)

    IOError: Error reading file ‘c:\users\jamesd~1\appdata\local\temp\inkscape-zs_jeu\eq.svg’: failed to load external entity “file:///c:/users/jamesd~1/appdata/local/temp/inkscape-zs_jeu/eq.svg”

    Any help would be much appreciated!

  23. Zedge
    December 21, 2011 at 4:21 am | #34

    Hello,

    Thanks for explanation, but I have the same problem described here :

    Michele :
    I did all the procedure you described but i have this error:
    textext.py:227: GtkWarning: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)’ failed
    txt.get_buffer().set_text(err_msg)
    Do you know how can i solve it?
    Many thanks in advance
    Michele

    Thanks for your help!

  24. Mohsen Heshmati
    December 26, 2011 at 12:48 am | #35

    It worked perfectly for me. Although at first I encountered some errors, I removed all the modifications and modified the file again very carefully… Indentations and spaces are very sensitive in this sort of file I suppose. Therefore, edit the lines one by one in each section and when you’re copy pasting, have an extra eye for your selection. thank you author again!

  25. Jackal
    January 17, 2012 at 5:57 pm | #36

    can you help me with error message after following your solutions:

    Traceback (most recent call last):
    File “textext.py”, line 212, in cb_ok
    self.callback(self.text, self.preamble_file, self.scale_factor)
    File “textext.py”, line 371, in
    converter_cls, old_node))
    File “textext.py”, line 389, in do_convert
    new_node = converter.convert(text, preamble_file, scale_factor)
    File “textext.py”, line 753, in convert
    self.pdf_to_svg()
    File “textext.py”, line 767, in pdf_to_svg
    raise NotImplementedError
    NotImplementedError

  26. February 3, 2012 at 11:45 am | #37

    Hello people from WordPress… Check this solution… It worked for me and now I have TeXtext running with Inkscape 0.48 without errors (In Linux of course….):

    http://gaortizg.wordpress.com/2012/01/29/how-to-write-with-latex-in-inkscape/

    See you later…..

  27. Lars Abrahamsson
    February 8, 2012 at 6:21 am | #38

    Caitlin :
    I fixed this by added the pstoedit path to the path system variable.

    I have all these paths entered, but still get the same error message, but in english:

    Traceback (most recent call last):

    File “textext.py”, line 937, in

    e.affect()

    File “C:\Program Files (x86)\Inkscape\share\extensions\inkex.py”, line 215, in affect

    self.effect()

    File “textext.py”, line 349, in effect

    % ‘;\n’.join(converter_errors))

    RuntimeError: No Latex -> SVG converter available:

    Pdf2Svg: Command pdf2svg failed: [Error 2] The system cannot find the file specified;

    PstoeditPlotSvg: Command pstoedit -help failed: [Error 2] The system cannot find the file specified;

    SkConvert: Command pstoedit failed: [Error 2] The system cannot find the file specified

  28. March 3, 2012 at 5:46 pm | #40

    Superb! Work just a you said. Had the same problem with inkscape 0.48 on OS X 10.6.8, installed dependencies via macports but when trying to use textext had the problem you described here. Replaced everything, restarted, and it works!

  29. April 3, 2012 at 7:41 pm | #41

    Thanks a lot, you saved my day!

  30. mkj
    April 9, 2012 at 10:35 pm | #42

    Caitlin :
    I fixed this by added the pstoedit path to the path system variable.

    please can you specify the way to add the pstoedit path to the path system variable. what did you write in the path system variable
    thanks in advance

  31. April 29, 2012 at 4:06 pm | #43

    Caitlin :
    I fixed this by added the pstoedit path to the path system variable.

    I have done the same. But I get the error message:
    Traceback (most recent call last):

    File “textext.py”, line 937, in

    e.affect()

    File “C:\Program Files (x86)\Inkscape\share\extensions\inkex.py”, line 215, in affect

    self.effect()

    File “textext.py”, line 349, in effect

    % ‘;\n’.join(converter_errors))

    RuntimeError: No Latex -> SVG converter available:

    Pdf2Svg: Command pdf2svg failed: [Error 2] The system cannot find the file specified;

    PstoeditPlotSvg: Command pstoedit -help failed: [Error 2] The system cannot find the file specified;

    SkConvert: Command pstoedit failed: [Error 2] The system cannot find the file specified

    Waiting for your reply…. Plz Plz help……

  32. Desperate person
    May 4, 2012 at 12:00 am | #44

    Hello, dear human being looking at your computer.
    I come to you as a last resort.

    It’s been two days that I’ve been trying to install Textext 0.4.4 for Inkscape 0.48 (under Windows XP, using Miktek 2.9)

    I followed
    - these instructions http://laconsigna.wordpress.com/2010/11/13/fixing-textext-on-inkscape-0-48/
    - and these instructions http://en.wikiversity.org/wiki/User:Egm6341.s10.team3.heejun/Inkscape#Install_Textext
    - and these instructions http://people.orie.cornell.edu/jmd388/design/guides/textext.pdf
    - and I’ve looked through this board https://bitbucket.org/pv/textext/issues

    But I keep having the same error message when I try to write something in Textext:

    Traceback (most recent call last):
    File “textext.py”, line 211, in cb_ok
    self.callback(self.text, self.preamble_file, self.scale_factor)
    File “textext.py”, line 370, in
    converter_cls, old_node))
    File “textext.py”, line 388, in do_convert
    new_node = converter.convert(text, preamble_file, scale_factor)
    File “textext.py”, line 752, in convert
    self.pdf_to_svg()
    File “textext.py”, line 766, in pdf_to_svg
    raise NotImplementedError
    NotImplementedError

    Please, help me…

  33. Lars Abrahamsson
    February 8, 2012 at 7:51 am | #45

    I should also mention that reading

    https://bitbucket.org/pv/textext/issue/55/textext-using-inkscape048

    it seams like it is better to use 32 bit software even if having a 64 bit computer. I that true?

    However, I replaced my GS View and Ghostscript with their respective 32 bit versions, but it did not make any difference to the error messages.

    /Lars

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.