0

here i tryied to run script with pypy3 c.py but above error occured , i installed pypy3 -m pip install pyshark but ...

pypy3 c.py

ModuleNotFoundError: No module named 'lxml.objectify'

import pyshark
import pandas as pd
import numpy as np
from multiprocessing import Pool
import re
import sys

temp_array  = []

cap = pyshark.FileCapture("ddos_attack.pcap")
#print(cap._extract_packet_json_from_data(cap[0]))

def parse(capture):
    print(capture)
    packet_raw = [i.strip('\r').strip('\t').split(':') for i in str(capture).split('\n')]
    packet_raw = map(lambda num:[num[0].replace('(',''),num[1].strip(')').replace('(','')] if len(num)== 2 else [num[0],':'.join(num[1:])] ,[i for i in packet_raw])
    raw = list(packet_raw)[:-1]
    cols = [i[0] for i in raw]
    vals = [i[1] for i in raw]
    temp_array.append(dict(zip(cols,vals)))
    return dict(zip(cols,vals))


def preprocess_dataset(x):
    count = 0
    temp = []
    #print(list(cap))
    #p = Pool(5)
    #r = p.map(parse,cap)
    #p.close()
    #p.join()
    #print(r)
    try:
       for i in list(cap):
          temp.append(parse(i))
          count += 1
    except Exception:
       print("somethin")

    data = pd.DataFrame(temp)
    print(data)
    data = data[['Packet Length','.... 0101 = Header Length','Protocol','Time to Live','Source Port','Length','Time since previous frame in this TCP stream','Window']]
    data.rename(columns={".... 0101 = Header Length": 'Header Length'})
    filtr = ["".join(re.findall(r'\d.',str(i))) for i in data['Time since previous frame in this TCP stream']]
    data['Time since previous frame in this TCP stream'] = filtr
    print(data.to_csv('data.csv'))

here i tryied to run script with pypy3 c.py but above error occured , i installed pypy3 -m pip install pyshark but ...

2 Answers2

0
  1. Check your terminal settings.
  2. Try to use another compiler like PyCharm.
RiveN
  • 2,595
  • 11
  • 13
  • 26
0

It seems lxml is not installed correctly. It is hard to figure out what is going on since you only show the last line of the traceback, and do not state what platform you are on nor what version of PyPy you are using. The lxml package is listed as a requirement for pyshark, so it should have been installed. What happens when you try import lxml ?

mattip
  • 2,360
  • 1
  • 13
  • 13