简体   繁体   中英

PyCharm Hanging on subprocess.communicate, script runs from CMD fine. PATH showing the same in both

I'm trying to execute a powershell script as a subprocess in Python, and pipe the output back into python. When I run this script via command line it works without a hitch, however now that I've thrown it into PyCharm it gets to the line with p.communicate and hangs.

I've printed the PATH from within pycharm and the CMD to compare, and they are line for line the same, not seeing many other answers as to why this wouldn't work.

Code:

p = subprocess.Popen(r'powershell.exe powershell\DNfinder.ps1 group "{}"'.format(group),
                       stdout=subprocess.PIPE)

print('Opened first subprocess') #This statement prints every time

groupDN = p.communicate()

Ran python script successfully within PyCharm after adding

stdin=subprocess.PIPE 

and

stderr=subprocess.PIPE

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