为什么我收到FileNotFoundError:[Errno 2]没有这样的文件或目录:'/ sbin / iwlist'

时间:2016-06-23 09:03:37

标签: python-3.5

使用以下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'?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:-1)

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

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

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