简体   繁体   English

使用 scapy 时 PyX 未正确安装

[英]PyX not installed correctly when using scapy

I am trying to use scapy in python 3.6 to parse pcap files, and of the features I am trying to use is pdfdump.我正在尝试在 python 3.6 中使用 scapy 来解析 pcap 文件,我尝试使用的功能是 pdfdump。

from scapy.all import *
packets = rdpcap('***path***/nitroba.pcap')
for packet in packets[0:1]:
  packet.psdump("isakmp_pkt.eps",layer_shift=1)

And I am getting the following error: "ImportError: PyX and its depedencies must be installed"我收到以下错误:“ImportError: PyX and its depedencies must be installed”

Obviously I installed it, and a simple "import pyx" works, but the error persists.显然我安装了它,并且一个简单的“import pyx”可以工作,但错误仍然存在。 I did some digging and found that the problem originates in this code:我做了一些挖掘,发现问题出在这段代码中:

def _test_pyx():
"""Returns if PyX is correctly installed or not"""
try:
    with open(os.devnull, 'wb') as devnull:
        r = subprocess.check_call(["pdflatex", "--version"], stdout=devnull, stderr=subprocess.STDOUT)
except:
    return False
else:
    return r == 0

when executed, it determines if pyx is installed correctly, but it says "FileNotFoundError: [WinError 2] The system cannot find the file specified".执行时,它会确定 pyx 是否安装正确,但会显示“FileNotFoundError: [WinError 2] The system cannot find the file specified”。

Ideas?想法?

就我而言(Ubuntu 18,scapy 2.4.3),我必须安装 pdflatex,即,

sudo apt install texlive-latex-base  

Got the answer myself - when I entered the scapy command line interface it said that I needed to install miktex which is a dependency of PyX, so I did.我自己得到了答案 - 当我进入 scapy 命令行界面时,它说我需要安装 miktex,它是 PyX 的一个依赖项,所以我这样做了。 The second error simply looks like a bug - it looks like there is a missing "import os" statement in the packet.py module, but there is an os.startfile in line 531.第二个错误看起来像是一个错误 - 看起来 packet.py 模块中缺少“import os”语句,但第 531 行中有一个 os.startfile。

I added it, and it worked:)我添加了它,它起作用了:)

Its currently 2022 in the future and this works for me with Jupyer labs running on Ubuntu 20.04目前是 2022 年,这对我来说适用于在 Ubuntu 20.04 上运行的 Jupyer 实验室

pip install pyx

At least this works for me:至少这对我有用:

from scapy.all import *

pkt = IP()

pkt.canvas_dump()

在此处输入图像描述

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

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