如何在 Python 中使用 pyx.canvas.writeGSfile() 时修复"FileNotFoundError"?



我想使用 Pyx 模块生成一个 jpeg 或 png 文件。我发现 pyx.canvas.writeGSfile((,我试图在以下代码中使用:

from pyx import *

def mark(x, y):
return path.circle(x, y, 0.1)

if __name__ == '__main__':
c = canvas.canvas()
# r = 70
f = trafo.scale(0.7, 1)
circle = path.circle(0, 0, 2)
a, b = circle.split([0, 2])
c.stroke(a, [style.linewidth.Thick, f])
d1 = f.apply(*circle.at(0.5*circle.arclen()))
d2 = f.apply(*circle.at(circle.arclen()))
c.fill(mark(*d1))
c.fill(mark(*d2))
c.writeGSfile('test.jpeg')

但它会反馈以下错误:

Traceback (most recent call last):
File "/Python/pyx/test.py", line 19, in <module>
c.writeGSfile('test.png')
File "AppDataLocalProgramsPythonPython36-32libsite-packagespyxcanvas.py", line 474, in writeGSfile
p = config.Popen(cmd, stdin=config.PIPE)
File "AppDataLocalProgramsPythonPython36-32libsite-packagespyxconfig.py", line 218, in Popen
return subprocess.Popen(cmd, *args, **kwargs)
File "AppDataLocalProgramsPythonPython36-32libsubprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "AppDataLocalProgramsPythonPython36-32libsubprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

我尝试调试,但我无法理解 processing.py 部分。有什么想法吗?

您需要安装 ghostscript (gs( 才能生成位图输出。

相关内容

  • 没有找到相关文章

最新更新