The Python Oracle

Python scapy import error

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT


Music by Eric Matyas
https://www.soundimage.org
Track title: Sunrise at the Stream

--

Chapters
00:00 Python Scapy Import Error
00:24 Answer 1 Score 1
00:40 Accepted Answer Score 9
00:59 Answer 3 Score 11
01:13 Answer 4 Score 2
01:20 Thank you

--

Full question
https://stackoverflow.com/questions/4273...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #scapy

#avk47



ANSWER 1

Score 11


If scapy is not installed in your system, then you can use this command to install scapy:

sudo apt-get install python-scapy




ACCEPTED ANSWER

Score 9


I think this may be a problem with your version:

If you are using Scapy v1.X:

from scapy import *

Otherwise, with Scapy V2.X+

from scapy.all import *

Is the way to go.

Hope that helps!




ANSWER 3

Score 2


Delete any file named scapy.py




ANSWER 4

Score 1


I think there was a change is scapy somewhere. I put the following code in my scapy projects so it remains compatible.

try:
    import scapy
except ImportError:
    del scapy
    from scapy import all as scapy