【发布时间】:2021-10-15 17:40:30
【问题描述】:
我在 Python 中使用 subprocess.Popen 并带有以下参数(我使用的是 pickle):
p = subprocess.Popen(args, stdout=subprocess.PIPE)
args 是:
['python', 'pyAppScript.py', 'C:\\Users\\Herve\\AppData\\Local\\Temp\\app.pkl', 2, 'event=True;-;event:bool', 'published=True;-;value:int']
app.pkl 之后的参数是我用来设置我的未编组实例的自定义参数。
我有以下堆栈跟踪:
File "D:\Java\framework\code\framework\samples\python\sample8\pythonHttpUtils.py", line 448, in createSubProcess
p = subprocess.Popen(args, stdout=subprocess.PIPE)
File "C:\Users\Herve\anaconda3\lib\subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Herve\anaconda3\lib\subprocess.py", line 1251, in _execute_child
args = list2cmdline(args)
File "C:\Users\Herve\anaconda3\lib\subprocess.py", line 553, in list2cmdline
for arg in map(os.fsdecode, seq):
File "C:\Users\Herve\anaconda3\lib\os.py", line 818, in fsdecode
filename = fspath(filename) # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not int
如果我不使用自定义参数而只是这样做:
p = subprocess.Popen(['python', 'pyAppScript.py', 'C:\\Users\\Herve\\AppData\\Local\\Temp\\app.pkl'], stdout=subprocess.PIPE)
完美运行。我做错了什么?
【问题讨论】: