如何在 Mac 上安装 pylibnet

发布于 2024-12-16 23:15:36 字数 2017 浏览 3 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中性美 2024-12-23 23:15:36

使用 MacPorts 安装 C 库后,是否安装了下载的 python libnet 包装器?如果没有,请 cd 到解压缩的 pylibnet 目录并尝试:

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

更新:从您更新的问题来看,现在看来您已经安装了另一个版本的 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-tarred pylibnet directory and try:

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

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 by Fink. 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 the setup.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文