Textext on Mac

Post questions on how to use or achieve an effect in Inkscape.
tomclose
Posts: 5
Joined: Tue May 06, 2008 12:44 pm

Textext on Mac

Postby tomclose » Tue May 06, 2008 1:03 pm

I am currently trying to get textext to work on Inkscape 4.6 on Mac OSX 10.4.

My first attempt was to download textext.py and textext.inc and just drop them into the Inkscape.app/Contents/Resources/Extensions file, as suggested on the textext website. Textext appeared in the Effects menu put when I clicked on it I got the following error:

Code: Select all

Traceback (most recent call last):
 File "Contents/Resources/extensions/textext.py", line 785, in ?
   e = TexText()
 File "Contents/Resources/extensions/textext.py", line 315, in __init__
   dest="text", default=None)
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/optparse.py",
line 820, in add_option
   option = self.option_class(*args, **kwargs)
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/optparse.py",
line 430, in __init__
   checker(self)
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/optparse.py",
line 499, in _check_type
   raise OptionError("invalid option type: %r" % self.type, self)
optparse.OptionError: option -t/--text: invalid option type: 'str'


A little phased by this I decided to try the other approach - downloading the dependencies using MacPorts and dropping the files into the .inkscape/extensions folder. (I didn't re-download the whole of inkscape via macports, just py25-gtk py25-lxml pstoedit).

This time when I ran it it complained that it couldn't find inkex. So I went the the Extensions folder, created a copy of inkex.py and placed it in the .inkscape/extensions folder. It now fails with the same error as the first attempt.

Does anyone know what's going wrong/has anyone managed to get textext working on mac osx10.4?

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Textext on Mac

Postby sas » Tue May 06, 2008 5:24 pm

The error is due to the old version of Python that you're using: the optparse module in Python 2.3 doesn't support "str" as a synonym of "string".

Also, you're using Python 2.5 packages (py25-gtk and py25-lxml) with Python 2.3, which probably won't work anyway. I suggest upgrading to Python 2.5.

tomclose
Posts: 5
Joined: Tue May 06, 2008 12:44 pm

Re: Textext on Mac

Postby tomclose » Wed May 07, 2008 2:21 am

Thanks for the tip. I upgraded my python to version 2.5.2. I then picked Effects->Textext. A dialogue box came up and I was able to enter an equation, however when I clicked "OK" I got the following error:

Code: Select all

/Users/tomclose/.inkscape/extensions/inkex.py:57: RuntimeWarning: Python C API version mismatch for module etree: This Python has API version 1013, module etree has version 1012.
  from lxml import etree
Traceback (most recent call last):
  File "/Users/tomclose/.inkscape/extensions/textext.py", line 786, in <module>
    e.affect()
  File "/Users/tomclose/.inkscape/extensions/inkex.py", line 154, in affect
    self.effect()
  File "/Users/tomclose/.inkscape/extensions/textext.py", line 355, in effect
    asker.ask(lambda t, p, s: self.do_convert(t, p, s, converter_cls, old_node))
  File "/Users/tomclose/.inkscape/extensions/textext.py", line 291, in ask
    self.callback(self.text, self.preamble_file, self.scale_factor)
  File "/Users/tomclose/.inkscape/extensions/textext.py", line 355, in <lambda>
    asker.ask(lambda t, p, s: self.do_convert(t, p, s, converter_cls, old_node))
  File "/Users/tomclose/.inkscape/extensions/textext.py", line 368, in do_convert
    new_node = converter.convert(text, preamble_file, scale_factor)
  File "/Users/tomclose/.inkscape/extensions/textext.py", line 607, in convert
    self.tex_to_pdf(latex_text, preamble_file)
  File "/Users/tomclose/.inkscape/extensions/textext.py", line 584, in tex_to_pdf
    exec_command(['pdflatex', self.tmp('tex')] + latexOpts)
  File "/Users/tomclose/.inkscape/extensions/textext.py", line 449, in exec_command
    raise RuntimeError("Command %s failed: %s" % (' '.join(cmd), e))
RuntimeError: Command pdflatex /tmp/tmpfXg8oN/tmp.tex -interaction=nonstopmode -halt-on-error failed: [Errno 2] No such file or directory


so, I can see this seems to have something to do with my version of python again. As far as I can tell the APIs for my version and the version I'm supposed to use are different. That said I don't fully understand the trace I have. Not sure what the best way to deal with it is. Should I just install a version of python earlier to 2.5.2 or is there a better way?

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Textext on Mac

Postby sas » Wed May 07, 2008 4:20 am

module etree has version 1012

I don't think this should happen with the py25-lxml that you installed. Have you also got an older version of lxml installed?

tomclose
Posts: 5
Joined: Tue May 06, 2008 12:44 pm

Re: Textext on Mac

Postby tomclose » Wed May 07, 2008 8:15 am

I'm slightly unsure about whether my system knows about what I've installed. I installed py25-lxml via macports. Despite spending a lot of time searching, I haven't been able to work out satisfactorily exactly what macports does. I think it might download things but keep them in a sandbox away from the main system to avoid conflicts. My inkscape was installed via the standard installer and so isn't in the macports sandbox (I think). Could this be causing the problem? If it is, what is the best set up to have to fix it? Would I have to run inkscape from the sandbox/would it matter?

I'm don't know how to find which version of lxml (if any) would be available to inkscape. My thoughts were to try "lxml -v" or "whereis lxml" at the command line but neither of them worked. I assume this is cos lxml isn't an executable but a library or something. Is this correct? What should I do to establish which version I'm using?

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Textext on Mac

Postby sas » Thu May 08, 2008 1:27 am

I don't know enough about Macs to help you much more on this. If you could install a version of lxml that's compiled to work with Python 2.5, and that's accessible to Inkscape, then you would probably be OK. However, the lxml site doesn't appear to have OS X binaries, so I don't know where you would get such a version.

It's possible that things would work if you downgraded to Python 2.4, as I think the lxml you have should work with that (though I'm not certain, as I can't find any information about which Python API version numbers correspond to which Python versions).

tomclose wrote:I'm don't know how to find which version of lxml (if any) would be available to inkscape. My thoughts were to try "lxml -v" or "whereis lxml" at the command line but neither of them worked. I assume this is cos lxml isn't an executable but a library or something. Is this correct?

Yes, it's a Python package. The following command should tell you where it is:

Code: Select all

python -c "print __import__('lxml')"


What should I do to establish which version I'm using?

Well, it's not so much the lxml version that you want to know, it's which version of Python it has been compiled for. I don't know how to determine that.

The lxml version can be determined like this:

Code: Select all

python -c "exec 'from lxml import etree\nprint etree.LXML_VERSION'"

E.g., (2, 0, 2, 0) means version 2.0.2.

tomclose
Posts: 5
Joined: Tue May 06, 2008 12:44 pm

Re: Textext on Mac

Postby tomclose » Fri May 09, 2008 3:46 am

When I do this:

tomclose wrote:The lxml version can be determined like this:

Code: Select all
python -c "exec 'from lxml import etree\nprint etree.LXML_VERSION'"


E.g., (2, 0, 2, 0) means version 2.0.2.


I get

Code: Select all

ImportError: No module named lxml


which is strange, as if I do "port installed" (which should tell me what macports has installed) it lists "py25-lxml @2.0.4_0 (active)". I guess this means the system just doesn't know where it is.

I downloaded lxml from here: http://pypi.python.org/pypi/lxml/2.0.5 and looked to see if I could see anything in the macports file that looked similar. I couldn't (but this could be my inadequacy rather than it not being there).

I then decided to try installing the whole of inkscape via macports (hoping that then it would be able to find the files) as described here: http://www.elisanet.fi/ptvirtan/softwar ... howto.html . I followed the instructions precisely, but the build failed with the error:

Code: Select all

configure: error: libgc (the Boehm Conservative Collector) 6.4+, is needed to compile inkscape -- http://www.hpl.hp.com/personal/Hans_Boehm/gc


I'm at a loss as to what to try next. I feel that it shouldn't be too hard to update/install a copy of lxml, but I don't know how/where to put it. Any suggestions?

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Textext on Mac

Postby sas » Sat May 10, 2008 5:53 am

tomclose wrote:I get

Code: Select all

ImportError: No module named lxml

which is strange, as if I do "port installed" (which should tell me what macports has installed) it lists "py25-lxml @2.0.4_0 (active)". I guess this means the system just doesn't know where it is.

It's also failing to find the other lxml, the one that was giving the API mismatch. I think this other lxml must be bundled with Inkscape.

I'm at a loss as to what to try next. I feel that it shouldn't be too hard to update/install a copy of lxml, but I don't know how/where to put it. Any suggestions?

I don't have any suggestions about installing lxml. But did you try using Python 2.4? This may be compatible with the lxml supplied with Inkscape, and it's probably not too old to work with TexText.

tomclose
Posts: 5
Joined: Tue May 06, 2008 12:44 pm

Re: Textext on Mac

Postby tomclose » Tue May 13, 2008 5:50 am

Is it possible to set it so that just inkscape would use python 2.4 or would I have to uninstall python 2.5 from my whole system? How would I choose to use python 2.4?


Return to “Help with using Inkscape”