Syntax error when running extensions

Asked by SasQ on 2012-11-30

I'm using Inkscape 0.48.3.1 r9886 on Gentoo Linux.
When I'm trying to run *any* extension from the Effects menu, I get error messages similar to the following one:

    Traceback (most recent call last):
      File "markers_strokepaint.py", line 19, in <module>
        import random, inkex, simplestyle, copy
      File "/usr/share/inkscape/extensions/inkex.py", line 29
        u'sodipodi' :u'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd',
                  ^
    SyntaxError: invalid syntax[/code]

It seems like some problem with Python, but I don't know why my Python doesn't recognize proper Python scripts from Inkscape. My python version is:

    python --version
    Python 3.2.3

I remember that few months ago, when I first compiled Inkscape, I used it without problems and everything worked fine, so I don't know why it stopped working.

Recompilation of the package doesn't change anything.

Any ideas what could be wrong and how to fix it?

Question information

Language:
English Edit question
Status:
Solved
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Solved by:
su_v
Solved:
2012-11-30
Last query:
2012-11-30
Last reply:
2012-11-30
Best su_v (suv-lp) said : #1

> I remember that few months ago, when I first compiled Inkscape,
> I used it without problems and everything worked fine, so I don't
> know why it stopped working.

Either Gentoo upgraded the system python version (from 2.x to 3.x), or you installed Python3 locally since then?

> Any ideas what could be wrong (…)

Inkscape's python-based extensions require Python2, and have not been migrated to Python3.

> and how to fix it?

If Gentoo now ships with Python3 as default Python version, ask the packager of Inkscape for Gentoo to address it (AFAIK other distros handle the migration from Python2 to Python3 more gracefully, without breaking existing apps).

Else - if you locally installed a newer version - try to figure out how to not replace the system python version (Python2) - e.g. keep python linked to Python2 (and use e.g. 'python3' to run the newer version).

SasQ (sasq1) said : #2

OK I've switched to Python 2 through Gentoo's native tool `eselect` and everything seems to work fine.
Thanks for your help.

su_v (suv-lp) said : #3

Additional information:

In case reverting the default python version in $PATH to Python 2 causes trouble with other applications for you: the interpreters for Inkscape's script-based extensions can be overridden on a 'per-user' level, by adding a custom key to Inkscape's preferences file (there is no GUI for this option in the preferences dialog):

1) quit all running Inkscape processes
2) Edit '~/.config/inkscape/perferences.xml', and search the group which holds settings for the extension system itself and options of various extensions:

  <group
     id="extensions"
     …
     org.ekips.filter.gears.teeth="24"
     org.ekips.filter.gears.pitch="20"
     org.ekips.filter.gears.angle="20" />

3) Insert a key for the interpreter, in your case 'python-interpreter', and set the string to the absolute path to the python binary which is compatible with Inkscape's current extension scripts:

  <group
     id="extensions"
     python-interpreter="/usr/bin/python2.7"
     …
     org.ekips.filter.gears.teeth="24"
     org.ekips.filter.gears.pitch="20"
     org.ekips.filter.gears.angle="20" />

4) Save the preferences file, and launch Inkscape to test the extensions…

SasQ (sasq1) said : #4

Thank you. This is very informative.
I added a note about that on Gentoo Forums, where I asked about Python versioning.
http://forums.gentoo.org/viewtopic-p-7194360.html