如何在M上安装pylibnet

2024-06-06 19:09:56 发布

您现在位置:Python中文网/ 问答频道 /正文

在示例.py我的档案:

import libnet

但当我执行时:

^{pr2}$

我得到了“ImportError:没有名为libnet的模块”

我如何安装它:

  • 转到http://pylibnet.sourceforge.net/并下载了它
  • 阅读自述文件,上面写着:在Mac上编译不起作用,用Macports加载它并使用python2.5
  • 安装并使用Python2.5
  • 安装libnet的方式是:sudo port install libnet11
  • 一切似乎都很好

只是错误仍然存在,它似乎没有安装。我现在能做什么?在

谢谢你的帮助!在

/编辑:

带有:“sudo/opt/local/bin/python2.5设置.py安装“,我得到:

Searching for libnet...
running install
running build
running build_ext
building 'libnet' extension
/Developer/usr/bin/llvm-gcc-4.2 -fno-strict-aliasing -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DLIBNET_MAJOR_VERSION=1 -DLIBNET_MINOR_VERSION=1 -DLIBNET_RELEASE=5 -DMAJOR_VERSION=2 -DMINOR_VERSION=0 -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c src/libnetmodule.c -o build/temp.macosx-10.7-x86_64-2.5/src/libnetmodule.o
In file included from src/context.c:110,
                 from src/libnetmodule.c:37:
src/builders.c: In function 'context_build_icmpv4_timestamp':
src/builders.c:726: error: 'n_time' undeclared (first use in this function)
src/builders.c:726: error: (Each undeclared identifier is reported only once
src/builders.c:726: error: for each function it appears in.)
src/builders.c:726: error: expected ';' before 'otime'
src/builders.c:727: error: expected ';' before 'rtime'
src/builders.c:728: error: expected ';' before 'ttime'
src/builders.c:735: error: 'otime' undeclared (first use in this function)
src/builders.c:735: error: 'rtime' undeclared (first use in this function)
src/builders.c:735: error: 'ttime' undeclared (first use in this function)
error: command '/Developer/usr/bin/llvm-gcc-4.2' failed with exit status 1

Tags: inbuildsrcbinuseversionlocalfunction
1条回答
网友
1楼 · 发布于 2024-06-06 19:09:56

在用MacPorts安装了C库之后,是否安装了下载的python libnet包装器?否则,cd到去焦油pylibnet目录并尝试:

sudo /opt/local/bin/python2.5 setup.py install

更新:根据您更新的问题,现在您似乎在/sw中安装了另一个版本的libnetc库,这是Fink安装的包的默认位置。您不应该尝试混合使用包管理器。选择一个-MacPorts,Fink,或者自制是OSX上最受欢迎的——并且坚持下去。作为一个短期修复方法,您可能需要编辑setup.py文件来删除对/sw的搜索。你应该在某个时候评估一下你用Fink和MacPorts安装了哪些软件包,选择一个,安装其中任何缺少的端口/软件包,然后完全删除另一个软件包系统。在

相关问题 更多 >