0

我按照官方 scapy 文档中的建议通过 MacPorts 安装了 scapy:http ://www.secdev.org/projects/scapy/doc/installation.html#mac-os-x

当我从命令行运行 scapy 时,它工作得很好。

但是现在我似乎无法将 scapy 导入 Python 解释器或 python 脚本中,这是错误。

Python 2.7.3 (default, Jan 31 2013, 22:54:33) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scapy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named scapy

我也尝试过使用 Python2.5,也不起作用。

Python 2.5.6 (r256:88840, Aug  5 2011, 03:29:42) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scapy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named scapy

我认为它与路径有关,但我不知道在 Mac 上的哪里编辑这些,尤其是我从 MacPorts 安装了 scapy。

4

1 回答 1

3

Macports 将所有内容安装到/opt/local. 所以我敢打赌,如果你运行/opt/local/bin/python,你将能够导入scapy

如果您需要scapy从默认 Python 安装中导入,则需要将其安装到该 Python 安装中(而不是其他,Macports,Python 安装)。

其他答案的相关信息:

于 2013-02-11T21:14:44.790 回答