I've been scouring forums for hours and can't seem to find a similar issue--could anyone help me understand why subprocess seems to work fine in IDLE but fails when I try to execute a script via the command line?
Here's an example of my code:
import subprocess
subprocess.check_output('notepad', shell=True)
In IDLE, Notepad immediately opens; when I run "python subtest.py" on the command line, I get:
Traceback (most recent call last):
File "C:\Python27\test\subtest.py", line 1, in <module>
import subprocess
File "C:\Python27\test\subprocess.py", line 8, in <module>
test = subprocess.Popen(my_command, shell=True, stdout=out, stderr=err)
AttributeError: 'module' object has no attribute 'Popen'
It appears to be failing on the import statement--I also tried:
import subprocess
try:
subprocess.check_output('notepad', shell=True)
except AttributeError as e:
print e
It fails with the same error--it never gets to the try/except block.
Any suggestions would be most appreciated!