错误导入Scapy的插入OSX Python解释器[MacPorts的安装](Error Impor

2019-10-17 17:01发布

我通过MacPorts的安装Scapy的这里推荐官方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的。

Answer 1:

Macports installs everything to /opt/local. So I bet if you run /opt/local/bin/python, you'll be able to import scapy.

If you need scapy to be importable from the default Python installation, you'll need to install it into that Python installation (instead of the other, Macports, Python installation).

Relavent information from other answers:

  • Running Macports Python #1.
  • Running MacPorts Python #2.


文章来源: Error Importing scapy into Python interpreter on OSX [MacPorts install]