Pydev 与 Scapy 给出“未解决的导入”错误
我正在尝试编写一个使用 scapy 模块的程序。我使用 PyDev 进行开发,但当我导入 Scapy 模块的某些部分时,它总是给我错误。我很确定我在 PyDev 中的导入路径设置正确。我在这里查看了涉及“未解决的导入”错误的其他一些问题。然而,我看到的建议似乎都没有帮助。
奇怪的是,它只是 scapy 模块的一部分不起作用。例如,当我这样做时,PyDev 不会抱怨
from scapy.all import Ether, sendp
但是,当我这样做时,
from scapy.all import IP, UDP
我会收到错误。
我想也许我导入了错误的模块,但是当我进入解释器并输入第二个示例时,它没有给出任何错误,然后我可以使用 IP(params) 创建 IP 数据包,这就是我在我的程序。
我使用 ubuntu 存储库安装了 scapy,但是当我开始遇到导入问题时,我从 scapy.net 下载了最新版本并使用了安装脚本。我什至复制了 zip 并将其放入我的 /usr/local/lib/python2.7/site-packages
文件夹中,并将其添加到 PyDev 中的 python 路径中。但似乎没有什么可以消除这个错误。
关于可能导致此问题的原因以及如何解决该问题有什么建议吗?
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 problems 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过将“scapy”添加到强制内置函数中?有关详细信息,请参阅:http://pydev.org/manual_101_interpreter.html。
Have you tried adding 'scapy' to the forced builtins? See: http://pydev.org/manual_101_interpreter.html for details.
我有机会再玩一些这个。我仍然不知道为什么 PyDev 在解释器中运行良好时会给我一个导入错误,但是,我确实找到了解决它的方法。要导入 IP、UDP 和 TCP 等内容,我现在使用以下内容
对于非 IPv4 内容
似乎工作得很好。
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
For non IPv4 stuff
seems to work just fine.