This is our old Q&A Site. Please post any new questions and answers at

Hey folks,

I need to sniff in Pyhton using pyShark on Windows. On UNIX systems I didn't have any problems.

On Windows a strange error occurs:

>>> cap = pyshark.LiveCapture(interface=nwdev)
>>> cap.sniff(timeout=10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\mu\WinPython-32bit-\python-2.7.10
\lib\site-packages\pyshark\capture\", line 109, in load_packets
    self.apply_on_packets(keep_packet, timeout=timeout)
  File "C:\Users\mu\WinPython-32bit-\python-2.7.10
\lib\site-packages\pyshark\capture\", line 201, in apply_on_packets
    return self.eventloop.run_until_complete(coro)
  File "C:\Users\mu\WinPython-32bit-\python-2.7.10
\lib\site-packages\trollius\", line 300, in  un_until_complete
    return future.result()
  File "C:\Users\mu\WinPython-32bit-\python-2.7.10
\lib\site-packages\trollius\", line 287, in result 
    raise self._exception
lxml.etree.XMLSyntaxError: Input is not proper UTF-8, indicate encoding !
Bytes: 0xE4 0x69 0x73 0x63, line 6, column 69

I work on a 32 bit Python version.

I even tried - I know that's very dangerous -


right in front of my pyshark call and in the parent processes. Without success.

Hope somebody is more familiar with pyShark running on Win. Thanks in advance!

asked 06 Apr '16, 22:31

elektm's gravatar image

accept rate: 100%

edited 06 Apr '16, 23:26

Guy%20Harris's gravatar image

Guy Harris ♦♦

After putting a lot of effort into the problem and spending a lot of time on searching for the error on the wrong place, I finally managed it to work.

It seems to be the problem, that the incoming data (in XML format) is not encoded the right way and pyshark does not cast to 'UTF-8'. While debugging it posed that it appeared to be in 'latin-1'.

I did the following:

  • I checked out the source from Github (
  • added following line between line 26 + 27 in src\pyshark\tshark\

    xml_pkt = xml_pkt.decode('latin-1')

  • python install and done

Took a lot of work and energy, but finaly solved for me!

permanent link

answered 14 Apr '16, 23:52

elektm's gravatar image

accept rate: 100%

edited 14 Apr '16, 23:55

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 06 Apr '16, 22:31

question was seen: 2,616 times

last updated: 14 Apr '16, 23:55

p​o​w​e​r​e​d by O​S​Q​A