感谢支持
我们一直在努力

Linux系统入门学习:修复“ImportError: No module named scapy.all”

问题:当我运行一个Python应用程序时,出现了这个提示消息“ImportError: No module named scapy.all”。我怎样才能修复这个导入错误呢?

Scapy是一个用Python写的灵活的数据包生成及嗅探程序。使用Scapy,你可以完成创建任意数据包并发送到网络上、从网络上或转储文件中读取数据包、转换数据包等工作。使用Scapy的通用包处理能力,你可以很容易地完成像SYN扫描、TCP路由跟踪以及OS指纹检测之类的工作。你也可以通过Import,将Scapy整合到其它工具中。

该导入错误表明:你还没有在你的Linux系统上安装Scapy。下面介绍安装方法。

安装Scapy到Debian, Ubuntu或Linux Mint

  1. $ sudo aptget install pythonscapy

安装Scapy到Fedora或CentOS/RHEL

在CentOS/RHEL上,你首先需要启用EPEL仓库。

  1. $ sudo yum install scapy

源码安装Scapy

如果你的Linux版本没有提供Scapy包,或者你想要试试最新的Scapy,你可以手工使用源码包安装。

下载最新版的Scapy,然后按照以下步骤安装。

  1. $ unzip scapylatest.zip
  2. $ cd scapy2.*
  3. $ sudo python setup.py install

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-12/110295.htm

How to set up EPEL repository on CentOS

If you are using CentOS or RHEL, it is strongly recommended that you configure EPEL (Extra Packages for Enterprise Linux) repository on your system. EPEL is a community effort to create a repository of high-quality add-on free software packages for RHEL-based distributions. Once you set up EPEL repository, you can use yum command to install any of close to 7,000 EPEL packages.

In order to enable EPEL repository on your CentOS system, you need to check CentOS version. To do that, run the following command.

$ cat /etc/RedHat-release

CentOS release 6.3 (Final)

Then install a corresponding EPEL release RPM package as follows. Note that the EPEL release RPM does not depend on the underlying processor architecture (e.g., 32-bit/64-bit x86, ppc, sparc, alpha, etc), so no need to pay attention to processor architecture difference.

Set up EPEL on CentOS 7

Starting from CentOS 7, EPEL release RPM package is available in “extras” repo. Therefore, simply use yum command to set up EPEL repository on these platforms:

$ sudo yum install epel-release
Set up EPEL on CentOS 6 or Earlier

For earlier versions of CentOS, you can use rpm command to download and install a RPM file manually as follows.

For CentOS/RHEL 6.*:

$ sudo rpm -Uvh http://mirrors.kernel.org/Fedora-epel/6/i386/epel-release-6-8.noarch.rpm

For CentOS/RHEL 5.*:

$ sudo rpm -Uvh http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm

During installation, you may see the following warning, which indicates that EPEL’s GPG key is missing.

warning: /var/tmp/rpm-tmp.3TKM2G: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY

The EPEL’s official GPG key is found in /etc/pki/rpm-gpg. Go ahead and import the GPG key as follows.

$ sudo sudo rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 (for CentOS 6)
$ sudo sudo rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 (for CentOS 7)

To verify that EPEL repository has been set up successfully, run the following command to list all available repositories on your system.

$ yum repolist

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-12/110295.htm

赞(0) 打赏
转载请注明出处:服务器评测 » Linux系统入门学习:修复“ImportError: No module named scapy.all”
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏