Reputation: 63
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()
Upvotes: 1
Views: 673
Reputation: 63
Ran python script successfully within PyCharm after adding
stdin=subprocess.PIPE
and
stderr=subprocess.PIPE
Upvotes: 3