python wifi模块使用 出现错误。

python wifi模块使用 出现错误,显示系统找不到指定文件?
wifi模块网站:https://wifi.readthedocs.io/e...
WiFi模块安装:pip install wifi

代码:

from  wifi  import  Cell,Scheme
cell = Cell.all('wlan0')

报错:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\wifipj.py", line 2, in <module>
    cell = Cell.all('wlan0')
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\wifi\scan.py", line 39, in all
    stderr=subprocess.STDOUT)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

再次感谢!

阅读 6.4k
1 个回答
新手上路,请多包涵

File "C:UsersAdministratorAppDataLocalProgramsPythonPython36-32libsite-packageswifiscan.py", line 39, in all

stderr=subprocess.STDOUT)

我们打开C:UsersAdministratorAppDataLocalProgramsPythonPython36-32libsite-packageswifiscan.py

找到`    def all(cls, interface):
    """
    Returns a list of all cells extracted from the output of iwlist.
    """
    try:
        iwlist_scan = subprocess.check_output(['/sbin/iwlist', interface, 'scan'],
                                              stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError as e:
        raise InterfaceError(e.output.strip())
    else:
        iwlist_scan = iwlist_scan.decode('utf-8')
    cells = map(Cell.from_string, cells_re.split(iwlist_scan)[1:])

    return cells`
    
    其中这句我们发现 哦 这TMD写死了  
     iwlist_scan = subprocess.check_output(['/sbin/iwlist', interface, 'scan'],
                                              stderr=subprocess.STDOUT)
         所以你的windows完全不支持 /sbin/iwlist wlan0 scan 这条命令啊 这是在linux下运行的。。。
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进