How to fix “ImportError: No module named scapy.all”

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
$ cd scapy-2.*
$ sudo python install
Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

Leave a comment

Your email address will not be published. Required fields are marked *