简体   繁体   中英

Python from sources: subprocess has no 'run' attribute

I have manually built python3.5.2 from sources on my ubuntu 15.10. The build process went well, but now when I execute below script

import subprocess
print(subprocess.run(["ls"]))

I receive following output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'run'

When I run same script on Windows (where I have installed python3.5.2 via installer) I receive expected output:

CompletedProcess(args='ls', returncode=0)

On my ubuntu machine subprocess.py is present in and it has "run" function defined. I anticipated that python3.5.2 could look for subprocess.py in libs folder for 2.7 (preinstalled on ubuntu) but this is not the case.

What could be wrong with my installation?

Try

import subprocess
import sys
print(sys.executable)
print(subprocess)

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