문제

The code below works completely fine. However, once the subprocess is called and the external python script is executed it starts popping up rapidly a command prompt as the output of the script is plain text. However, we have tried everything to disable that pop up. We tried adding 'shell=False' and 'shell=None'. We even tried to edit the external script itself and modify its subprocess calls but it has none.

if os.path.exists(oldpath): shutil.copy(root.wgetdir + "\\" + root.website.get() + "\\" + item, keyworddir + "\\" + item)
            shellreturn = subprocess.check_output(["C:\Python34\python",root.wgetdir + "\html2text.py", keyworddir + "\\" + item])
            print(shellreturn)
            shelllist = shellreturn.decode().splitlines()
도움이 되었습니까?

해결책

Thanks to the related post from @J.F. Sebastian, I was able to figure out how to eliminate the shell popup. Below is the code I used.

startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW      
shellreturn = subprocess.check_output(["C:\Python34\python", root.wgetdir + "\html2text.py", keyworddir + "\\" + item], startupinfo=startupinfo) #this could be any subprocess.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top