1

I am trying to run in PyX module in Python.

It is a simple program called "mplot.py":

 from pyx import *
 g = graph.graphxy(width=8)
 g.plot(graph.data.function("y(x)=sin(x)/x", min=-15, max=15))
 g.writePDFfile("function")

I want to do this to make plot.

I run it as normal

 C:\Users\Tony>py myplot.py

But I get strange and long error message:

 Traceback (most recent call last):
 File "myplot.py", line 4, in <module>
 g.writePDFfile("function")
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\sitepackages\pyx\canvas.py", line 50, in wrappedindocument
 return method(d, file, **write_kwargs)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site 
packages\pyx\document.py", line 193, in writePDFfile
 pdfwriter.PDFwriter(self, f, **kwargs)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\pdfwriter.py", line 316, in __init__
 catalog = PDFcatalog(document, self, registry)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\pdfwriter.py", line 143, in __init__
 self.PDFpages = PDFpages(document, writer, registry)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\pdfwriter.py", line 202, in __init__
 page = PDFpage(page, pageno, self, writer, registry)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\pdfwriter.py", line 236, in __init__
 self.PDFcontent = PDFcontent(page, writer, self.pageregistry)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\pdfwriter.py", line 268, in __init__
 page.processPDF(contentfile, awriter, acontext, registry, self.bbox)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\document.py", line 135, in processPDF
 self._process("processPDF", *args)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
  packages\pyx\document.py", line 129, in _process
 getattr(cc, processMethod)(contentfile, writer, context, registry, bbox)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\graph\graph.py", line 191, in processPDF
 canvas.canvas.processPDF(self, file, writer, context, registry, bbox)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\canvas.py", line 238, in processPDF
 item.processPDF(file, writer, context, registry, nbbox)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\canvas.py", line 238, in processPDF
  item.processPDF(file, writer, context, registry, nbbox)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\canvas.py", line 238, in processPDF
 item.processPDF(file, writer, context, registry, nbbox)
 [Previous line repeated 1 more time]
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\text.py", line 887, in processPDF
  self.dvicanvas.processPDF(file, writer, context, registry, abbox)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\text.py", line 851, in dvicanvas
 self.do_finish()
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
  packages\pyx\text.py", line 1212, in do_finish
 self.go_finish()
  File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
  packages\pyx\text.py", line 1338, in go_finish
 self._execute("\\end%\n", self.texmessages_end_default +
 self.texmessages_end, STATE_TYPESET, STATE_DONE)
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\text.py", line 1125, in _execute
 raise e
 File "C:\Users\Tony\Programs\Python\Python37-32\lib\site
 packages\pyx\text.py", line 1103, in _execute
 raise TexResultError("TeX dvifile messages expected")
 pyx.text.TexResultError: TeX dvifile messages expected
 The expression passed to TeX was:
 \end%
 After parsing the return message from TeX, the following was left:
 *(see the transcript file for additional information)
 Output written on "C:\Users\Tony\Temp\pyx3z6ter8i\texp
 ut.dvi" (25 pages, 1800 bytes).
 Transcript written on "C:\Users\Tony\Temp\pyx3z6ter8i\
 texput.log".

How to fix this error and get my plot? How to fix this error and get my plot? How to fix this error and get my plot?How to fix this error and get my plot? How to fix this error and get my plot? How to fix this error and get my plot? How to fix this error and get my plot? How to fix this error and get my plot? How to fix this error and get my plot? How to fix this error and get my plot?How to fix this error and get my plot?How to fix this error and get my plot? How to fix this error and get my plot?How to fix this error and get my plot?

Any help is much appreciated. Thank you

Nigel1
  • 95
  • 8

1 Answers1

1

You can fix it by adding the line

text.set(engine=text.TexEngine, texmessages_end=[text.texmessage.ignore])

immediately after the import statement. However, this will just silence the issue. A proper fix will be part of a future PyX release (see https://github.com/pyx-project/pyx/issues/8).

wobsta
  • 721
  • 4
  • 5
  • 1
    In addition, you may test whether https://github.com/pyx-project/pyx/commit/e214537208b5a1c297687c62f9a586ff2bc7db00 fixed the issue for you. It should, but I cannot test myself ... – wobsta Aug 10 '19 at 04:52
  • Sorry, how do I test whether this github link is the fix? i copy paste the code somewhere? – Nigel1 Aug 10 '19 at 07:50
  • 1
    Sure, you can download a patch https://github.com/pyx-project/pyx/commit/e214537208b5a1c297687c62f9a586ff2bc7db00.patch or the full file https://raw.githubusercontent.com/pyx-project/pyx/e214537208b5a1c297687c62f9a586ff2bc7db00/pyx/text.py – wobsta Aug 11 '19 at 08:53
  • Sorry, I download the patch and put it where? What command to do? – Nigel1 Aug 11 '19 at 09:44
  • 1
    To apply the patch, you need to use the patch utility, which is quite common to software devs. Now, earier for you is the second link to the full file text.py (as you don't know how to work with the patch file yourself). It has the patch already applied. You need to replace the text.py file on your system with this file and check whether the issue has been resolved without the additional line I suggested in my answer. – wobsta Aug 12 '19 at 04:16