[英]Python, linux: Using wifi Cell and Scheme, how do I connect to a network?
For reference: https://wifi.readthedocs.io/en/latest/scanning.html#connecting-to-a-network供参考: https://wifi.readthedocs.io/en/latest/scanning.html#connecting-to-a-network
I have been successful in getting a list of wireless networks, by executing the following commands:通过执行以下命令,我已成功获取无线网络列表:
from wifi import Cell, Scheme
cells = list(Cell.all('wlan0'))
my_wifi_cell = cells[some_index]
But when I try to use it (as in the example above):但是当我尝试使用它时(如上例所示):
scheme = Scheme.for_cell('wlan0', 'home', my_wifi_cell, 'my password')
scheme.save()
scheme.activate()
While running python elevated, scheme.activate() fails with the following traceback:在运行 python 提升时,scheme.activate() 失败并出现以下回溯:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/wifi/scheme.py", line 172, in activate
subprocess.check_output(['sbin/ifdown', self.interface], stderr=subprocess.STDOUT)
File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/usr/lib/python3.7/subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: command '['/sbin/ifdown', 'wlan0']' returned non-zero exit status 1.
Sorry if there are any mistakes, I had to manually type that over.对不起,如果有任何错误,我不得不手动输入。 Anyway, I verified that the ssid and passkey were correct, I'm just not sure how to resolve this error.
无论如何,我验证了 ssid 和密码是正确的,我只是不确定如何解决这个错误。 Any thoughts?
有什么想法吗?
Update: According to https://github.com/rockymeza/wifi/issues it looks like this just doesn't work anymore(?) Is there a fix for this, or should I just start looking somewhere else?更新:根据https://github.com/rockymeza/wifi/issues看来这不再起作用了(?)有解决办法,还是我应该开始寻找其他地方?
I believe what you are missing is root privilege.我相信您缺少的是root权限。 Let try to run it with root
让我们尝试用 root 运行它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.