2

I want to write the Ethernet packets capture while using python. I googling and found that I should using Pcap library or PyShark but I try to import pcap, it said that can not found module name Pcap, so I try to using PyShark instance but it show like this on Python shell

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import pyshark
  File "D:\Python27\lib\site-packages\pyshark-0.3.3-py2.7.egg\pyshark\__init__.py", line 1, in <module>
    from pyshark.capture.live_capture import LiveCapture
  File "D:\Python27\lib\site-packages\pyshark-0.3.3-py2.7.egg\pyshark\capture\live_capture.py", line 1, in <module>
    from pyshark.capture.capture import Capture
  File "D:\Python27\lib\site-packages\pyshark-0.3.3-py2.7.egg\pyshark\capture\capture.py", line 7, in <module>
    import trollius as asyncio
ImportError: No module named trollius

About this problem, what should I do? How can I import the library to python?

OS is Windows 8.1 and Python version 2.7.9

Martijn Pieters
  • 889,049
  • 245
  • 3,507
  • 2,997
Cashchii
  • 27
  • 2
  • 10

1 Answers1

1

The pyshark project requires that trollius is installed for Python versions before Python 3.4. You'll need to install that separately.

It should have been installed when you installed the pyshark package however. Make sure to always use a tool like pip to install your packages and dependencies like these are taken care of automatically; the pyshark project declares the dependencies correctly:

install_requires=['lxml', 'py', 'trollius', 'logbook'],
Martijn Pieters
  • 889,049
  • 245
  • 3,507
  • 2,997
  • @Cashchii: Since this is Python 2.7.9, you can use `python -m pip install trollius`. For installing wheels, you first need to install the `wheel` support: `python -m pip install wheel` – Martijn Pieters Feb 15 '15 at 14:28
  • I try to install 'trollius' but it shown like this picture >> https://www.dropbox.com/s/3sx08um4jyq208v/Untitled.png?dl=0 – Cashchii Feb 15 '15 at 14:29
  • I tried to install pip and then install pycap but I got like this picture https://www.dropbox.com/s/sgb3c3z216fl8yn/Untitled.png?dl=0 , what does it mean? I'm not sure about it . – Cashchii Feb 16 '15 at 16:16
  • @Cashchii: that library is trying to compile a C extension and cannot find the header file needed to compile. – Martijn Pieters Feb 16 '15 at 16:18
  • @Cashchii: there are [installation instructions](https://code.google.com/p/pypcap/source/browse/trunk/INSTALL) in the project repository. To compile on Windows, you'll need a compiler (Microsoft Visual Studio compatible with the Python version) and *winpcap with development headers*. – Martijn Pieters Feb 16 '15 at 16:23