来自 : subprocess has no 'run' attribute 源的 Python

标签 python python-2.7 ubuntu build subprocess

我已经在我的 ubuntu 15.10 上从源代码手动构建了 python3.5.2。构建过程进行得很顺利,但是现在当我执行下面的脚本时

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

我收到以下输出:

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

当我在 Windows 上运行相同的脚本时(我已经通过安装程序安装了 python3.5.2),我收到了预期的输出:

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

在我的 ubuntu 机器上存在 subprocess.py 并且它定义了“运行”函数。 我预计 python3.5.2 可以在 libs 文件夹中查找 subprocess.py for 2.7(预装在 ubuntu 上),但事实并非如此。

我的安装可能有什么问题?

最佳答案

尝试

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

关于来自 : subprocess has no 'run' attribute 源的 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41084235/

相关文章:

bash 检查目录中所有文件的扩展名

python - 使用 Fabric : how to edit Django settings? 自动化 Django 设置

python - Tensorflow:有没有办法将训练损失存储在 tf.Estimator 中

python - 使用参数手动调用内置类型函数

python - EOF 发生违反 Python ftplib 协议(protocol)

python - 脚本执行后保留命名空间和变量值

python - 如何在 vim 中获取 Python 帮助?就像vim一样使用:h

python - 在 PC 上同时运行 Python 2.7 和 3.5

linux - 在 Windows 7 机器上使用 git

c++ - 简单的 openGL 程序无法在 ubuntu 中链接