简体   繁体   English

在python 3上安装dpkt

[英]Install dpkt on python 3

I am trying to install dpkt on python 3 and I get the following error when I am installing: 我正在尝试在python 3上安装dpkt,安装时出现以下错误:

(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. 我看到“ ah”是导入的第一个模块,而ah.py在dpkt目录中。

Same thing I get if I try to install using pip. 如果尝试使用pip安装,也会得到相同的结果。

I also ran into this issue today. 我今天也遇到了这个问题。

I gave installing under Python 2.7 a go, and it worked straight away. 我允许在Python 2.7下进行安装,并且可以立即运行。 Dpkt hasn't been updated to work in 3.x yet by the looks of things. 从外观上看,Dpkt尚未更新为可在3.x中运行。

I used the 2to3 tool that comes with Python 3.4 to convert the source: 我使用了Python 3.4随附的2to3工具来转换源:

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: 对于ieie80211.py以外的所有文件,此操作均成功完成,我必须手动对其进行编辑以分隔导入,以便读取:

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. 完成此操作后,您可以正常运行python 3.4并使用setup.py install。

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. 更新:我无法使用这种方法读取pcap文件-看起来需要更仔细的移植。

As of version 1.9.1 dpkt supports Python 3 从1.9.1版开始,dpkt支持Python 3

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM