IOError:[Errno 1]不允许操作

时间:2013-08-21 08:35:25

标签: python-2.7 operation ioerror

我正在使用Eclipse作为运行ubuntu的Python 2.7.3中的第一个代码 我是python和linux的bigginner,也使用模块pythonwifi 0.3.1。 该代码应扫描frequency_channel_mapwifi.scan()中的频率,以检索具有for-loop中列出的信息的对象

#!/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,但找到了我理解的任何内容

PS。 stackoverflow上的第一篇文章,请深刻了解

1 个答案:

答案 0 :(得分:2)

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