subprocess.checkoutput() 给出错误 No such file or directory: 'netsh' in Orange PI

问题描述

我正在尝试获取橙色 pi 上可用的 wifi 设备,并尝试使用我在 jsn 文件中的用户名和密码一一连接

Armbian 21.05.2 Focal with Linux 5.10.34-sunxi

python 脚本就是这个

import subprocess
import os
print("Hello")
devices = subprocess.check_output(['netsh','wlan','show','network'])
devices = devices.decode('ascii')
devices = devices.replace("\r","")
print(devices)

我收到以下错误

Traceback (most recent call last):
  File "hello.py",line 4,in <module>
    devices = subprocess.check_output(['netsh','network'])
  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: 'netsh'

我尝试使用 shell = True

devices = subprocess.check_output(['netsh','network'],shell = True)

但是我出错了

wlan: 1: netsh: not found
Traceback (most recent call last):
  File "hello.py",shell=True)
  File "/usr/lib/python3.8/subprocess.py",line 512,in run
    raise CalledProcessError(retcode,process.args,subprocess.CalledProcessError: Command '['netsh','network']' returned non-zero exit status 127.

这是什么问题。

解决方法

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

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

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