简体   繁体   中英

Subprocess in python don't allow read

i need your help to debug something I use subprocess in python to run an external application with this command

subprocess.run(["Program", "-o", "-e", "Desktop",new_path])

new_path is a var where i store the path of the app. So it's seem's good but when i start the app with python3 main.py i get

 File "C:\Python27\lib\site-packages\run\__init__.py", line 145, in __new__
process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell)

 File "C:\Python27\lib\site-packages\run\__init__.py", line 121, in create_process
shlex.split(command),

 File "C:\Python27\lib\shlex.py", line 279, in split
return list(lex)

 File "C:\Python27\lib\shlex.py", line 269, in next
token = self.get_token()

File "C:\Python27\lib\shlex.py", line 96, in get_token
raw = self.read_token()


File "C:\Python27\lib\shlex.py", line 124, in read_token
nextchar = self.instream.read(1)

AttributeError: 'list' object has no attribute 'read'

Run the subprocess with shell=True

subprocess.run(["Program", "-o", "-e", "Desktop",new_path], shell=True)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM