WriteTeX icon indicating copy to clipboard operation
WriteTeX copied to clipboard

Traceback after WriteTeX installation on Ubuntu

Open Axo-Fv opened this issue 4 years ago • 4 comments

Recently I heard about this extension for inkscape. So I tried to install, following the steps mentioned in the official page. My operating system is ubuntu 18.04. I copied both files on /usr/share/inkscape/extensions/ On LateX Source I put $\frac{x^2}{z}$. But when I click on 'Apply' a window with the below message is showed... Traceback (most recent call last): File "writetex.py", line 376, in <module> e.affect() File "/usr/share/inkscape/extensions/inkex.py", line 283, in affect self.effect() File "writetex.py", line 180, in effect self.merge_pdf2svg_svg(svg_file) File "writetex.py", line 306, in merge_pdf2svg_svg WriteTexNS] = self.text.encode('string-escape') LookupError: unknown encoding: string-escape Also I tried changing all the options on PDF to SVG converter and Latex Command used to Compile to pdflatex, but the traceback persist. Finally, I ran which pdf2svg on the terminal and the output was /usr/bin/pdf2svg.

Axo-Fv avatar May 05 '21 01:05 Axo-Fv

Today I was reading about another package called Tex Tex. When I saw their requirements and I started to check if I have python2.7, pdf2svg, pdflatex, lualatex, xelatex. However I did not remember installed something about gtk packages. So I run the command sudo apt-get install python-gtk2 python-gtksourceview on my CLI. Then I opened Inkscape just for intuition and I tried to type the same equation I mentioned above...and it works. I don't know if this is the solution to fix my problem, but if you have some traceback check if you have the installed the requirements previously...one by one.

Axo-Fv avatar May 06 '21 00:05 Axo-Fv

Thanks for feedback. Based on the error message, your inkscape is using python3 instead of python2 as python interpreter. I cannot reproduce the error on my ubuntu machine.

wanglongqi avatar May 06 '21 14:05 wanglongqi

hi, i was facing similar issue after upgrading inkscape to 1.0.2 (1.0.2+r75+1) on ubuntu 18.04.5. i recently installed python3.9.6 on my machine. however, inkscape 0.92.5 is working fine.

if you have the same error as below, you can try:

  • for inkscape 1.0.2, i copied the files from this repo 1.0.x/writetex.inx, 1.0.x/writetex.py to ~/.config/inkscape/extensions as suggested and it should work. i tried initially to copy them to /usr/share/inkscape/extensions but it failed. copying to home works.
  • i read here that i need to change the python interpreter of writertex in ~/.config/inkscape/preferences.xml, to use python2.7. this is not required. my default python points to python3.9.6. i hope this helps.

thanks

error:

writetex.py:33: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("-f", "--formula",
writetex.py:37: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("-p", "--preamble",
writetex.py:41: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--read-as-line",
writetex.py:45: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("-s", "--scale",
writetex.py:49: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("-i", "--inputfile",
writetex.py:53: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("-c", "--pdftosvg",
writetex.py:57: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--action", action="store",
writetex.py:60: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("-r", "--rescale",
writetex.py:64: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("-l", "--latexcmd",
writetex.py:68: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("-t", "--tosvg",
writetex.py:347: DeprecationWarning: Effect.affect is now `Effect.run()`. The `output` argument has changed.
  e.affect()
writetex.py:282: DeprecationWarning: inkex.etree was removed, use "from lxml import etree"
  doc = inkex.etree.parse(svg_file)
writetex.py:273: DeprecationWarning: inkex.etree was removed, use "from lxml import etree"
  svgout = inkex.etree.Element(inkex.addNS('g', 'WriteTexNS'))
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, locale, imp, stat
Traceback (most recent call last):
  File "writetex.py", line 347, in <module>
    e.affect()
  File "/usr/share/inkscape/extensions/inkex/deprecated.py", line 181, in affect
    return self.run(args=args)
  File "/usr/share/inkscape/extensions/inkex/base.py", line 140, in run
    self.save_raw(self.effect())
  File "writetex.py", line 164, in effect
    self.merge_pdf2svg_svg(svg_file)
  File "writetex.py", line 286, in merge_pdf2svg_svg
    WriteTexNS] = self.text.encode('string-escape')
LookupError: unknown encoding: string-escape

sbelharbi avatar Aug 19 '21 12:08 sbelharbi

Nice. In short, if you saw "OptionParser" in the error message, it means you are using 0.9.x version with python3 interpreter. The solution is either change interpreter to python2, or use the 1.0.x version, which is compatible with python3.

wanglongqi avatar Aug 19 '21 12:08 wanglongqi