在Python中运行“命令-v dnf”的问题

问题描述

我正在尝试运行以下代码

import subprocess
def install_curl():
    result = subprocess.check_output(['command','-v','dnf']) # 
    if not result:
        print("You should Install curl")
    else:
        result = subprocess.check_output(['command','apt'])
        print(result)
install_curl()

然后我收到此错误

Traceback (most recent call last):
  File "/home/pbravodez1/projects/Automate_task/test_gpg.py",line 98,in <module>
    install_curl()
  File "/home/pbravodez1/projects/Automate_task/test_gpg.py",line 91,in install_curl
    result = subprocess.check_output(['command','dnf']) # 
  File "/usr/lib/python3.8/subprocess.py",line 411,in check_output
    return run(*popenargs,stdout=PIPE,timeout=timeout,check=True,File "/usr/lib/python3.8/subprocess.py",line 489,in run
    with Popen(*popenargs,**kwargs) as process:
  File "/usr/lib/python3.8/subprocess.py",line 854,in __init__
    self._execute_child(args,executable,preexec_fn,close_fds,line 1702,in _execute_child
    raise child_exception_type(errno_num,err_msg,err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'command'

您对如何运行此“命令”以检查操作系统中安装了哪个程序包管理器有任何想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)