开发者

Pydev with Scapy Gives "Unresolved Import" Error

开发者 https://www.devze.com 2023-04-09 03:32 出处:网络
I\'m trying to write a program that uses the scapy modules.I\'m using PyDev for my development but it keeps giving me errors when I import certain parts of the Scapy module.I\'m pretty sure I have my

I'm trying to write a program that uses the scapy modules. I'm using PyDev for my development but it keeps giving me errors when I import certain parts of the Scapy module. I'm pretty sure I have my import paths in PyDev set up correctly. I've looked at some of the other questions involving "Unresolved Import" errors on here. However, none of the suggestions I saw seemed to help.

The weird thing is that it is only part of the scapy modules that don't work. So for instance PyDev doesn't complain when I do

from scapy.all import Ether, sendp

However, when I do

from scapy.all import IP, UDP

I get errors.

I thought maybe I was importing the wrong modules but when I go to the interpreter and type in the second example it gives no errors and then I can create IP packets using IP(params), which is what I'm trying to do in my program.

I installed scapy using the ubuntu repositories, but when I started having import prob开发者_Go百科lems I downloaded the latest version from scapy.net and used the setup script. I even copied the zip and put it in my /usr/local/lib/python2.7/site-packages folder and added it to my python path in PyDev. But nothing seems to get rid of the error.

Any suggestions on what could be causing this and how to fix it?


Have you tried adding 'scapy' to the forced builtins? See: http://pydev.org/manual_101_interpreter.html for details.


I got a chance to play some more with this. I still don't know why PyDev gives me an import error when it works fine in the interpreter, however, I did find a way around it. To import things like IP, UDP, and TCP I'm now using the following

from scapy.layers.inet import IP, TCP, UDP

For non IPv4 stuff

from scapy.all import <Module Name>

seems to work just fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消