簡體   English   中英

使用 scapy 時 PyX 未正確安裝

[英]PyX not installed correctly when using scapy

我正在嘗試在 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)

我收到以下錯誤:“ImportError: PyX and its depedencies must be installed”

顯然我安裝了它,並且一個簡單的“import pyx”可以工作,但錯誤仍然存在。 我做了一些挖掘,發現問題出在這段代碼中:

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

執行時,它會確定 pyx 是否安裝正確,但會顯示“FileNotFoundError: [WinError 2] The system cannot find the file specified”。

想法?

就我而言(Ubuntu 18,scapy 2.4.3),我必須安裝 pdflatex,即,

sudo apt install texlive-latex-base  

我自己得到了答案 - 當我進入 scapy 命令行界面時,它說我需要安裝 miktex,它是 PyX 的一個依賴項,所以我這樣做了。 第二個錯誤看起來像是一個錯誤 - 看起來 packet.py 模塊中缺少“import os”語句,但第 531 行中有一個 os.startfile。

我添加了它,它起作用了:)

目前是 2022 年,這對我來說適用於在 Ubuntu 20.04 上運行的 Jupyer 實驗室

pip install pyx

至少這對我有用:

from scapy.all import *

pkt = IP()

pkt.canvas_dump()

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM