0

so when i'm trying to import http for scapy in a python code like this

from scapy.layers.http import *

it returns this error

ModuleNotFoundError: No module named 'scapy.layers.http'

but in the scapy terminal it works perfecty fine, i tried to look up the error on google but i can't find anything about it, all i find is peoples telling that you have to import http like this (from scapy.layers.http import *) but that doesn't work for me, any idea how i can fix that? or other ways i can filter http packets?

test code:

from scapy.all import *
from scapy.layers.http import *


def ccc(pack):
    return HTTP in pack


a = sniff(lfilter=ccc, count=1)

a.show()

error:

Traceback (most recent call last):
  File "C:/Users/name/Desktop/python tests/dontdeleteitit'stest.py", line 2, in <module>
    from scapy.layers.http import *
ModuleNotFoundError: No module named 'scapy.layers.http'
Rebel
  • 23
  • 6

1 Answers1

0

Since you are using PyCharm(mentioned in comments) can you cross check your installed libraries ? you can use this shortcut on windows -> ctlr + alt + s

You should see scapy in the list if it is installed( please see below highlighted item). enter image description here

if it is not installed then click on + button search for scapy and install it directly.

If everything looks good then probably you need to configure you runner to point to correct interpreter where scapy is installed.

Shakeel
  • 1,869
  • 15
  • 23
  • Oh, i realized i had an 2.4.0 version of scapy, this is why it didn't worked, now i updated it and it works, thank you so much :D – Rebel Jun 06 '20 at 11:41