简体   繁体   English

在OSX上将scapy导入Python解释器时出错[MacPorts安装]

[英]Error Importing scapy into Python interpreter on OSX [MacPorts install]

I installed scapy via MacPorts as recommended here in the official scapy documentation: http://www.secdev.org/projects/scapy/doc/installation.html#mac-os-x 我按照此处的官方Scapy文档中的建议通过MacPorts安装了Scapy: http : //www.secdev.org/projects/scapy/doc/installation.html#mac-os-x

It works just fine when I run scapy from the command-line. 当我从命令行运行scapy时,它工作得很好。

However now I can't seem to import scapy into the Python interpreter or in a python script, here's the error. 但是现在我似乎无法将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

I have also tried with Python2.5, doesn't work either. 我也尝试过使用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

I think it has to do with the path somehow, but I don't know where to edit those on Mac, especially that I installed scapy from MacPorts. 我认为这与路径有关,但是我不知道在Mac上的编辑位置,特别是我从MacPorts安装了Scapy。

Macports installs everything to /opt/local . Macports将所有内容安装到/opt/local So I bet if you run /opt/local/bin/python , you'll be able to import scapy . 所以我敢打赌,如果您运行/opt/local/bin/python ,您将能够导入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). 如果您需要从默认的Python安装中导入scapy ,则需要将其安装到该Python安装中(而不是Macports,Python安装中的其他安装)。

Relavent information from other answers: 从其他答案中获取信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM