如何在 Mac 上安装 pylibnet
在 example.py 文件中,我有:
import libnet
但是当我通过以下方式执行它时:
/opt/local/bin/python2.5 example.py
我收到“ImportError:没有名为 libnet 的模块”
我如何尝试安装它:
- 转到 http://pylibnet.sourceforge.net/ 并下载它
- 并阅读 README 文件,其中显示:在 Mac 上编译不起作用,用 Macports 加载它并使用
- 已安装的 python 2.5 和用过的python 2.5
- 通过以下方式安装 libnet: sudo port install libnet11
- 一切似乎都很好
只是错误仍然存在,它似乎没有安装。我现在能做什么?
感谢您的任何帮助!
/编辑:
使用:“sudo /opt/local/bin/python2.5 setup.py install”,我得到:
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
In example.py file I have:
import libnet
but when I execute it via:
/opt/local/bin/python2.5 example.py
I'm getting "ImportError: No module named libnet"
How I tried to install it:
- went to http://pylibnet.sourceforge.net/ and downloaded it
- read the README file which said: compiling on Mac doesn't work, load it with Macports and use python 2.5
- installed and used python 2.5
- installed libnet via: sudo port install libnet11
- everything seems to be fine
Just the error stays, it doesn't seem to be installed. What can i do now?
Thanks for any kind of help!
/Edit:
with: "sudo /opt/local/bin/python2.5 setup.py install", i'm getting:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 MacPorts 安装 C 库后,是否安装了下载的 python
libnet
包装器?如果没有,请cd
到解压缩的pylibnet
目录并尝试:更新:从您更新的问题来看,现在看来您已经安装了另一个版本的 libnet C 库 < code>/sw 这是
Fink
安装的软件包的默认位置。您不应该尝试混合包管理器。选择其中之一 - MacPorts、Fink 或 Homebrew 是 OS X 上最受欢迎的 - 并坚持使用。作为短期修复,您可以编辑setup.py
文件以删除对/sw
的搜索。您应该在某个时候评估您使用 Fink 和 MacPorts 安装了哪些软件包,选择一个,在其中安装任何缺少的端口/软件包,然后完全删除另一个软件包系统。After you installed the C libraries with MacPorts, did you then install the python
libnet
wrapper you downloaded? If not,cd
to the de-tarredpylibnet
directory and try:Update: From your updated question, it now appears you have another version of the libnet C libraries installed in
/sw
which is the default location for packages installed byFink
. You should not attempt to mix package managers. Pick one - MacPorts, Fink, or Homebrew are the most popular on OS X - and stick with it. As a short term fix, you could probably edit thesetup.py
file to remove the search for/sw
. You should at some point evaluate what packages you have installed with Fink and MacPorts, pick one, install any missing ports/packages in it, and entirely delete the other package system.