如何使用 Python 修复 Pyx 模块中的回溯错误?

How to fix traceback error in Pyx module with Python?

我正尝试 运行 在 Python 的 PyX 模块中。

这是一个名为 "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")

我想做这个来做剧情

我运行正常

 C:\Users\Tony>py myplot.py

但我收到奇怪且长的错误消息:

 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".

如何修复这个错误并得到我的情节? 如何修复此错误并获取我的情节? 如何修复此错误并获取我的绘图?如何修复此错误并获取我的绘图? 如何修复此错误并获取我的情节? 如何修复此错误并获取我的情节? 如何修复此错误并获取我的情节? 如何修复此错误并获取我的情节? 如何修复此错误并获取我的情节? 如何修复此错误并获取我的绘图?如何修复此错误并获取我的绘图?如何修复此错误并获取我的绘图? 如何修复此错误并获取我的绘图?如何修复此错误并获取我的绘图?

非常感谢任何帮助。谢谢

您可以通过添加行

来修复它
text.set(engine=text.TexEngine, texmessages_end=[text.texmessage.ignore])

紧跟在导入语句之后。但是,这只会使问题沉默。适当的修复将成为未来 PyX 版本的一部分(参见 https://github.com/pyx-project/pyx/issues/8)。