The source of this error is this (sub "begin_capture")...
for t, pkt in self.pcap:
stream = dpkt.ethernet.Ethernet(pkt)
data = stream.data.data
self.ip = "%d.%d.%d.%d" %tuple(map(ord, list(stream.data.dst)))
if data.dport == self.port:
Its not that it behaves differently in a shell, as I don't run it in any shell; just through console. This is the link to the entire module: http://pastebin.ca/614338