Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python子进程错误_Python_Subprocess_Python Imaging Library - Fatal编程技术网

Python子进程错误

Python子进程错误,python,subprocess,python-imaging-library,Python,Subprocess,Python Imaging Library,我正在尝试使用PIL实现一个小的filters,并且已经走了这么远,但是我被这个回溯所困扰 Traceback (most recent call last): File "C:/Users/Ajay/PycharmProjects/pygram/test.py", line 5, in <module> pg.execute("convert {filename} -modulate 120,10,100 -fill '#222b6d' -colorize 20 -ga

我正在尝试使用
PIL
实现一个小的filters,并且已经走了这么远,但是我被这个回溯所困扰

Traceback (most recent call last):
  File "C:/Users/Ajay/PycharmProjects/pygram/test.py", line 5, in <module>
    pg.execute("convert {filename} -modulate 120,10,100 -fill '#222b6d' -colorize 20 -gamma 0.5 -contrast -contrast {filename}")
  File "C:\Users\Ajay\PycharmProjects\pygram\pygram.py", line 22, in execute
    error = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
  File "C:\Python27\lib\subprocess.py", line 575, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'convert git.jpg -modulate 120,10,100 -fill '#222b6d' -colorize 20 -gamma 0.5 -contrast -contrast git.jpg' returned non-zero exit status 4
test.py

from pygram import PyGram

pg = PyGram("git.jpg")

pg.execute("convert {filename} -modulate 120,10,100 -fill '#222b6d' -colorize 20 -gamma 0.5 -contrast -contrast {filename}")
pg.border()
请帮忙,我哪里做错了?

您的测试无效

您尝试执行以下字符串:

"convert {filename} -modulate 120,10,100 -fill '#222b6d' -colorize 20 -gamma 0.5 -contrast -contrast {filename}"

但是您没有传入“filename”的值。有关更多详细信息,请参见此处:

如果直接在控制台中运行问题命令,会发生什么情况?
convert
是Windows路径上的可执行文件吗?@Tom我不知道你在问什么?Python正试图从运行文件的目录运行
convert git.jpg-modulate 120,10100-fill'#222b6d'-colorize 20-gamma 0.5-contrast-contrast git.jpg
。如果在同一目录下的命令提示符下直接运行该命令,会发生什么情况?我得到这个
无效参数--modulate
请确保在您的系统上运行。也可以在Windows上的命令中尝试双引号(
)而不是单引号(
)(或使用PowerShell)。
{filename}
正确更改为
git.jpg
。顺便说一句,它不起作用。输出文件名不应与输入文件名相同。您确实应该测试并确保该命令能够在DOS提示符或shell中单独工作。这将使调试更容易。
"convert {filename} -modulate 120,10,100 -fill '#222b6d' -colorize 20 -gamma 0.5 -contrast -contrast {filename}"