【问题标题】:How to run step-cli using subprocess.run() in python如何在 python 中使用 subprocess.run() 运行 step-cli
【发布时间】:2022-01-20 04:24:08
【问题描述】:

我在 Windows 上并在 Windows 上安装了该步骤。 安装成功。

step certificate inspect https://smallstep.com

当我运行它时,它被确认了。

但是当我在 python 中运行下面的代码时,它引发了一个错误。

result = subprocess.run(['step', 'ca', 'certificate', '--ca-url=https://x.x.x.x', email, crt, key, '--root=root.crt', '--provisioner-password-file=provision.txt'])

这是错误:

FileNotFoundError: [WinError 2] The system cannot find the file specified

但是文件路径是正确的。我确定。

【问题讨论】:

    标签: python subprocess


    【解决方案1】:

    您确定要导入子流程吗?

    import subprocess
    

    您可以测试子进程是否正确运行。

    result = subprocess.run([sys.executable, "-c", "print('ocean')"])
    

    如果运行良好。它会说像“海洋”。

    【讨论】:

    • 是的,这是我的文件路径的问题
    猜你喜欢
    • 1970-01-01
    • 2020-07-29
    • 2021-06-03
    • 2018-05-02
    • 1970-01-01
    • 2019-01-03
    • 1970-01-01
    • 2022-01-19
    • 2020-02-12
    相关资源
    最近更新 更多