Install dpkt on python 3

11k views Asked by At

I am trying to install dpkt on python 3 and I get the following error when I am installing:

(venv)[root@miura dpkt-1.8]# python setup.py install
Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    import dpkt
  File "/root/dpkt-1.8/dpkt/__init__.py", line 13, in <module>
    import ah
ImportError: No module named 'ah'

What am I missing? I see that "ah" is the first module imported, and ah.py is inside the dpkt directory.

Same thing I get if I try to install using pip.

2

There are 2 answers

0
aliask On

I also ran into this issue today.

I gave installing under Python 2.7 a go, and it worked straight away. Dpkt hasn't been updated to work in 3.x yet by the looks of things.

I used the 2to3 tool that comes with Python 3.4 to convert the source:

python C:\Python34\Tools\Scripts\2to3.py -w dpkt-1.8

This succeeded for all files except ieee80211.py, which I had to edit manually to separate the imports so that it read:

from . import dpkt
import socket, struct

Once you've done that, you can run python 3.4 and use setup.py install as you would normally.

I haven't done any extensive testing however so keep in mind that a script converted the source...

Update: I am not able to read a pcap file with this method - it looks like more careful porting is required.

0
Andrey Grachev On

As of version 1.9.1 dpkt supports Python 3

https://pypi.python.org/pypi/dpkt/1.9.1