gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 07:26:26 35 4
gpt4 key购买 nike

我正在尝试在 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])

紧接在导入语句之后。然而,这只会平息这个问题。适当的修复将成为 future PyX 版本的一部分(请参阅 https://github.com/pyx-project/pyx/issues/8 )。

关于python - 如何使用 Python 修复 Pyx 模块中的回溯错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57425910/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com