Inkscape0.92でTexを利用するときの注意点です。

結論:Pythonのバージョンは2.7です。3では、動作しません。

まず、LaTexを実行してみました。

エクステンション>レンダリング>LaTex で実行できます。すると下記のようなエラーが表示されました。

Traceback (most recent call last):
File “/usr/share/inkscape/extensions/inkex.py”, line 113, in
from lxml import etree
ModuleNotFoundError: No module named ‘lxml’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “eqtexsvg.py”, line 31, in
import inkex, os, tempfile, sys, xml.dom.minidom
File “/usr/share/inkscape/extensions/inkex.py”, line 119, in
“python-lxml\n\nTechnical details:\n%s” % (e, )))
File “/usr/share/inkscape/extensions/inkex.py”, line 101, in errormsg
if isinstance(msg, unicode):
NameError: name ‘unicode’ is not defined

このエラーメッセージから下記のサイトがヒットしました。

https://stackoverflow.com/questions/52046845/changing-the-python-interpreter-for-inkscape

つまり、ホームディレクトリにあるInkscapeの設定ファイルにpythonのインタープリターを2.7と設定するのです。設定ファイルは、

~/.config/inkscape/preferences.xml

です。

<group>
id="extensions"
python-interpreter="/usr/bin/python2.7"
...........................

とpython-interpreterを追記しても、Inkscapeを再起動するとこの追記した設定部分だけが消えています。つまり、反映されませんでした。

また、textextをインストール(参照https://textext.github.io/textext/install/linux.html)して、実行すると、下記のようなエラーが表示されました。

[TexText][ERROR ]: Python 2.7 is required, but found 3.6.7

やっぱり、2.7が必須のようです。

私の場合は、ホームディレクトリ内につくっていた~/bin/pythonのショートカット(python3.6)を削除しました。これで、システムとしてpythonは2.7として認識されます。代わりに、anaconda3のpython3.7をインストールしました。ローカルのターミナルでpythonと打つと、3.7として認識されていることが確認できます。

これで、textextが正常に利用できるようになりました。ただし、LaTexの方はデフォルトの数式ではエラー?が表示され、数式が埋め込めませんが、\$\frac{1}{2}\$などの単純な数式は、Inkscapeに埋め込めました。

今回は、textextが使えればよいので、一応、これで良しとして対策完了とします。

次は、textextで日本語を表示させてみます。