gpt4 book ai didi

python-2.7 - IOError: [Errno 1] 不允许操作

转载 作者:行者123 更新时间:2023-12-02 01:58:48 24 4
gpt4 key购买 nike

我在运行 ubuntu 的 Python 2.7.3 中使用 Eclipse 作为我的第一个代码我是 python 和 linux 的大佬,也使用模块 pythonwifi 0.3.1 。该代码应扫描 frequency_channel_map 中的频率,并且 wifi.scan() 应检索包含 for 循环中列出的信息的对象

#!/usr/bin/python2

from pythonwifi.iwlibs import Wireless

frequency_channel_map = {
2412000000: "1",
2417000000: "2",
2422000000: "3",
2427000000: "4",
2432000000: "5",
2437000000: "6",
2442000000: "7",
2447000000: "8",
2452000000: "9",
2457000000: "10",
2462000000: "11",
2467000000: "12",
2472000000: "13",
2484000000: "14",
}

wifi = Wireless("wlan")

for ap in wifi.scan():
print "SSID: " + ap.essid
print "AP: "+ ap.bssid
print "Signal: " + str(ap.quality.getsignallevel())
print "Frequ: "+ str(ap.frequency.getfrequency())
print "Chanel :"+ frequency_channel_map.get(ap.frequency.getfrequency())
print "____"

得到那个问题

    Traceback (most recent call last):
File "/home/andreas/workspace/test/firstModule.py", line 22, in <module>
print wifi.commit()
File "/usr/local/lib/python2.7/dist-packages/pythonwifi.egg/pythonwifi/iwlibs.py", line 679, in commit
pythonwifi.flags.SIOCSIWCOMMIT)
File "/usr/local/lib/python2.7/dist-packages/pythonwifi.egg/pythonwifi/iwlibs.py", line 1028, in iw_set_ext
return self.iw_get_ext(ifname, operation, data)
File "/usr/local/lib/python2.7/dist-packages/pythonwifi.egg/pythonwifi/iwlibs.py", line 1023, in iw_get_ext
result = self._fcntl(request, ifreq)
File "/usr/local/lib/python2.7/dist-packages/pythonwifi.egg/pythonwifi/iwlibs.py", line 1010, in _fcntl
return fcntl.ioctl(self.sockfd.fileno(), request, args)
IOError: [Errno 1] Operation not permitted

我不知道为什么会这样。自 2 天以来搜索 IOError: [Errno 1] Operation not permitted 但发现了我理解的任何内容

附言。第一次在stackoverflow上发帖,请见谅

最佳答案

通常是错误;不允许操作,如果您不在 root 中,就会发生,即,确保您以 root 用户身份运行此 python 脚本,去做这个。打开你的 linux 终端,并输入 sudo su。你会得到一个提示询问你的密码,这个密码与你用来登录 linux 的密码相同。然后运行您的 Python 代码。

关于python-2.7 - IOError: [Errno 1] 不允许操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18352585/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com