python scapy模块安装后引用错误_python – scapy安装失败在osx与dnet导入错误

在OSX上安装Scapy模块后,遇到dnet导入错误。已经尝试过一些解决方案,但未成功。脚本使用Python 2.7.5,能正常在Python解释器中运行`import scapy`,但在脚本执行时,提示`ImportError: No module named dnet`。已安装pcapy和libdnet,但问题依然存在。配置和编译libdnet时出现警告和错误。
摘要由CSDN通过智能技术生成

麻烦安装Scapy,它是必需的依赖。我已经花了一些时间Googling解决方案,但所有的“解决方案”似乎影响旧版本的Python,或者根本不起作用。

脚本:

#!/usr/bin/python

import threading

import Queue

import time

from scapy.all import *

class WorkerThread(threading.Thread) :

def __init__(self, queue, tid) :

threading.Thread.__init__(self)

self.queue = queue

self.tid = tid

print 'Worker: %d' %self.tid

def run(self) :

total_ports = 0

while True :

port = 0

try :

port = self.queue.get(timeout=1)

except Queue.Empty :

print 'Worker %d exiting. %d ports scanned' %(self.tid, total_ports)

return

#Scanning begins

ip = sys.argv[1]

response = sr1(IP(dst=ip)/TCP(dport=port, flags='S'), verbose=False, timeout=.2)

if response :

if response[TCP].flags == 18 :

print 'ThreadID: %d: Got port no. %d status: OPEN' %(self.tid, port)

self.queue.task_done()

total_ports += 1

queue = Queue.Queue()

threads = []

for i in range(1, 10) :

print 'Creating WorkerThread : %d' %i

worker = WorkerThread(queue, i)

worker.setDaemon(True)

worker.start()

threads.append(worker)

print 'WorkerThread %d created' %i

for j in range(1, 100) :

queue.put(j)

queue.join()

for item in threads :

item.join()

print 'Scanning complete'

Python版本是2.7.5,并经过Python验证。

which python

/usr/bin/python

当脚本执行时,我得到以下错误:

./multi-threaded-scanner.py

Traceback (most recent call last):

File "./multi-threaded-scanner.py", line 6, in

from scapy.all import *

File "/Library/Python/2.7/site-packages/scapy/all.py", line 16, in

from arch import *

File "/Library/Python/2.7/site-packages/scapy/arch/__init__.py", line 75, in

from bsd import *

File "/Library/Python/2.7/site-packages/scapy/arch/bsd.py", line 12, in

from unix import *

File "/Library/Python/2.7/site-packages/scapy/arch/unix.py", line 20, in

from pcapdnet import *

File "/Library/Python/2.7/site-packages/scapy/arch/pcapdnet.py", line 160, in

import dnet

ImportError: No module named dnet

我可以使用Scapy和Python交互式解释器,并在Python解释器中运行import scapy不产生错误。

当脚本最初运行时,pcapy模块丢失,但是我安装了

然后问题切换到dnet,我找不到解决方案。

A similar post,似乎描述了同样的问题,但解决方法没有任何效果。

有人可以在这个问题上再说一遍吗?

用于安装pcapy和libdnet的命令:

libdnet-1.11.tar.gz(01-19-2005)

` ~/Downloads/libdnet-1.11 

chmod a+x configure

~/Downloads/libdnet-1.11 

./configure && make`

退出成功

Pcapy:最新的稳定版本(0.10.8),更新于2010年8月26日

〜/下载/ pcapy-0.10.8

sudo python setup.py安装

密码:

运行安装

运行构建

运行build_ext

运行build_scripts

运行install_lib

运行install_scripts

将/usr/local/bin/96pings.pcap的模式更改为777

将/usr/local/bin/pcapytests.py更改为777模式

运行install_data

运行install_egg_info

删除/Library/Python/2.7/site-packages/pcapy-0.10.8-py2.7.egg-info

写/Library/Python/2.7/site-packages/pcapy-0.10.8-py2.7.egg-info

〜/下载/ pcapy-0.10.8

使用新标志进行编译的结果

~/Downloads/libdnet-1.12 

sudo CFLAGS='-arch i386 -arch x86_64' ./configure --prefix=/usr and archargs='-arch i386 -arch x86_64' make

configure: WARNING: you should use --build, --host, --target

configure: WARNING: you should use --build, --host, --target

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

/Users/richardcurteis/Downloads/libdnet-1.12/config/missing: Unknown `--is-lightweight' option

Try `/Users/richardcurteis/Downloads/libdnet-1.12/config/missing --help' for more information

configure: WARNING: 'missing' script is too old or missing

checking for a thread-safe mkdir -p... config/install-sh -c -d

checking for gawk... no

checking for mawk... no

checking for nawk... no

checking for awk... awk

checking whether make sets $(MAKE)... yes

checking whether make supports nested variables... yes

checking whether to enable maintainer-specific portions of Makefiles... no

checking build system type... Invalid configuration `and': machine `and' not recognized

configure: error: /bin/sh config/config.sub and failed

~/Downloads/libdnet-1.12 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值