我想使用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 "\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyx\canvas.py", line 474, in writeGSfile
p = config.Popen(cmd, stdin=config.PIPE)
File "\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyx\config.py", line 218, in Popen
return subprocess.Popen(cmd, *args, **kwargs)
File "\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
我尝试调试,但是在理解processing.py部分时遇到了麻烦。有什么想法吗?
答案 0 :(得分:0)
您需要安装ghostscript(gs)才能生成位图输出。