2

我有一个脚本可以在 cmd 上执行一组命令。但我收到以下错误

代码:

`with open(r'InputData.txt') as values:
    subprocess.run(['kubectl', 'run', 'kafka-producer152',
            '-ti', '--image=strimzi/kafka:0.19.0-kafka-2.4.0',
            '--rm=true', '--restart=Never',
            '--', 'bin/kafka-console-producer.sh',
            '--broker-list', '11.63.211.79:30044',
            '--topic', 'randomnewtopic'],
        stdin=values,check=True, text=True)`

错误: File "Producer.py", line 40, in <module> subprocess.run(['kubectl', 'run',podName, File "C:\Users\AngadiVB\AppData\Local\Programs\Python\Python38-32\lib\site-packages\run\__init__.py", line 145, in __new__ process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell) File "C:\Users\AngadiVB\AppData\Local\Programs\Python\Python38-32\lib\site-packages\run\__init__.py", line 121, in create_process shlex.split(command), File "C:\Users\AngadiVB\AppData\Local\Programs\Python\Python38-32\lib\shlex.py", line 311, in split return list(lex) File "C:\Users\AngadiVB\AppData\Local\Programs\Python\Python38-32\lib\shlex.py", line 300, in __next__ token = self.get_token() File "C:\Users\AngadiVB\AppData\Local\Programs\Python\Python38-32\lib\shlex.py", line 109, in get_token raw = self.read_token() File "C:\Users\AngadiVB\AppData\Local\Programs\Python\Python38-32\lib\shlex.py", line 140, in read_token nextchar = self.instream.read(1) AttributeError: 'list' object has no attribute 'read'

注意:第 40 行是 subprocess.run

4

0 回答 0