python - 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','wlan','show','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,
File "/usr/lib/python3.8/subprocess.py", 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','wlan','show','network'],shell = True)
但我得到了错误
wlan: 1: netsh: not found
Traceback (most recent call last):
File "hello.py", line 4, in <module>
devices = subprocess.check_output(['netsh','wlan','show','network'],shell=True)
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 512, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['netsh', 'wlan', 'show', 'network']' returned non-zero exit status 127.
有什么问题。
解决方案
推荐阅读
- c# - Xamarin android 在活动之间传递时间并从其他活动重置
- arrays - -a 标志是创建 bash 数组所必需的吗?
- html - Why does GMAIL removes inline style from my HTML email?
- html - 为什么宽度/高度不适用于非定位伪元素?
- c - 计算字符串中数字的频率
- django - 如何防止 Django 的管理界面静默抑制错误?
- python - 如何从 Heroku 的客户端填充数据库
- sql - Datediff 以分钟为单位,考虑到自定义银行假期、维护天数和工作时间
- c++ - 如何计算数组中使用的索引数
- python - 气流:仅当当前相同的实例未运行时,如何为每小时工作流(如触发器)指定条件?