How to get pylibnet installed on a Mac

397 Views Asked by At

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
1

There are 1 best solutions below

3
On

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.