【问题标题】:Why do I receive FileNotFoundError: [Errno 2] No such file or directory: '/sbin/iwlist'为什么我收到 FileNotFoundError: [Errno 2] No such file or directory: '/sbin/iwlist'
【发布时间】:2016-10-25 12:17:33
【问题描述】:

使用以下 Python 代码:

>>> from wifi import Cell, Scheme
>>> Cell.all('wlan0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/site-packages/wifi/scan.py", line 39, in all
    stderr=subprocess.STDOUT)
File"/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 629, in check_output
**kwargs).stdout
  File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 696, in run
with Popen(*popenargs, **kwargs) as process:
   File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 950, in __init__
restore_signals, start_new_session)
  File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1540, in _execute_child
raise child_exception_type(errno_num, err_msg) 
FileNotFoundError: [Errno 2] No such file or directory: '/sbin/iwlist'

为什么我会收到错误消息FileNotFoundError: [Errno 2] No such file or directory: '/sbin/iwlist'?

【问题讨论】:

    标签: python-3.5


    【解决方案1】:

    您要么没有安装iwlist,要么安装在不同的路径上,例如/usr/sbin/iwlist。如果是这种情况,那么您可以创建一个符号链接,例如:

    `ln -s /usr/sbin/iwlist /sbin/iwlist'

    如果没有安装,那么你需要安装它。

    【讨论】:

    • 您遗漏了一个非常重要的细节——作者使用的是 Mac OS,而 iwlist 是一个 Linux 无线工具。
    【解决方案2】:

    您尝试使用的 Python 模块仅适用于 Linux——“iwlist”可执行文件是特定于 Linux 的。该模块与 macOS 不兼容——您需要找到一个支持 macOS 的 Python 模块,或者在 Linux 计算机上使用该模块。 (虚拟机将工作,因为它无法访问您机器的无线硬件。)

    【讨论】:

      【解决方案3】:

      需要重新安装无线工具,所以你得到iwconfig

      sudo apt-get install --reinstall wireless-tools
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-01-24
        • 1970-01-01
        • 2018-03-07
        • 1970-01-01
        • 2012-08-25
        • 2019-10-14
        • 1970-01-01
        • 2023-03-06
        相关资源
        最近更新 更多