How to fix "ImportError: No module named scapy.all"

Last updated on July 10, 2020 by Dan Nanni

Question: When I run a Python application, I am getting "ImportError: No module named scapy.all" message. How can I fix this import error?

Scapy is a flexible packet generation and sniffer program written in Python. Using Scapy, you can create arbitrary packets, send them to the wire, reading packets from the wire or a dump file, transform packets, etc. Using Scapy's generic packet manipulation capabilities, you can easily do things like SYN scan, TCP traceroute, and OS fingerprinting. You can also integrate Scapy into another tool by importing it.

The import error indicates that you do not have Scapy installed on your Linux system. Here is how to install Scapy on Linux.

Install Scapy on Debian, Ubuntu or Linux Mint

$ sudo apt-get install python-scapy

Install Scapy on Fedora or CentOS/RHEL

On CentOS/RHEL, you need to enable EPEL repository first.

$ sudo yum install scapy

Install Scapy from the Source

If your Linux distribution does not offer Scapy package or you want to try the latest Scapy, you can install Scapy manually from the source.

Download the latest version of Scapy, and install it as follows.

$ unzip scapy-latest.zip
$ cd scapy-2.*
$ sudo python setup.py install

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean