Python subprocess has no attribute "check_output"

Viewed 2530

I have code that uses subprocess.check_output just fine, I had to reinstall Ubuntu 16.04 and afterwards it's complaining that it now can't find the attribute check_output.

import subprocess

p = subprocess.check_output("here is a command", shell=True)

/usr/bin/python2.7 /home/username/subprocess.py
Traceback (most recent call last):
  File "/home/username/subprocess.py", line 1, in <module>
    import subprocess
  File "/home/username/subprocess.py", line 4, in <module>
    p = subprocess.check_output("here is a command", shell=True)
AttributeError: 'module' object has no attribute 'check_output'

Note that I am using Python2.7 which according to this post here should resolve this problem but it doesn't.

subprocess.check_output() module object has out attribute 'check_output'

What gives? I tried pip install subprocess or pip uninstall subprocess but no luck. How do I update subprocess to the latest version so that it has the check_output attribute? I don't want to use Popen.

1 Answers
Related