Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Mac上安装pylibnet_Python_Installation_Macports_Libnet - Fatal编程技术网

Python 如何在Mac上安装pylibnet

Python 如何在Mac上安装pylibnet,python,installation,macports,libnet,Python,Installation,Macports,Libnet,在example.py文件中,我有: import libnet 但当我通过以下方式执行时: /opt/local/bin/python2.5 example.py 我收到“ImportError:没有名为libnet的模块” 我是如何安装它的: 转到并下载了它 阅读自述文件,其中说:在Mac上编译不起作用,请使用Macports加载它,并使用python 2.5 已安装并使用python 2.5 通过sudo端口安装libnet安装libnet11 一切似乎都很好 只是错误仍然存在,它

在example.py文件中,我有:

import libnet
但当我通过以下方式执行时:

/opt/local/bin/python2.5 example.py
我收到“ImportError:没有名为libnet的模块”

我是如何安装它的:

  • 转到并下载了它
  • 阅读自述文件,其中说:在Mac上编译不起作用,请使用Macports加载它,并使用python 2.5
  • 已安装并使用python 2.5
  • 通过sudo端口安装libnet安装libnet11
  • 一切似乎都很好
只是错误仍然存在,它似乎没有安装。我现在能做什么

谢谢你的帮助

/编辑:

通过“sudo/opt/local/bin/python2.5 setup.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

在安装了带有MacPorts的C库之后,是否安装了下载的python
libnet
包装器?如果没有,请将
cd
转到去焦油
pylibnet
目录,然后尝试:

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

更新:根据您更新的问题,现在看来您在
/sw
中安装了另一个版本的libnet C库,这是
Fink
安装的软件包的默认位置。您不应该尝试混合使用包管理器。选择一个——MacPorts、Fink或自制是OSX上最流行的——并坚持使用它。作为短期修复,您可能可以编辑
setup.py
文件以删除对
/sw
的搜索。您应该在某个时候评估您使用Fink和MacPorts安装的软件包,选择一个,在其中安装任何缺少的端口/软件包,并完全删除另一个软件包系统。

谢谢,我试过了,但他试图构建它,我得到了编译错误谢谢!你说得对,我以前用过Fink,但也没用。现在我调整了setup.py,它不再寻找/sw。无论如何,我得到了另一个错误=/。请参阅我的最新问题。您可以看到什么吗?似乎缺少包含
n_time
的def的include文件。我认为应该在
libinet
中。您可以尝试修补
setup.py
或C源代码。对不起,我今天没有时间进一步讨论这个问题。