Unable to import scapy.all in python while root user

I have a python file named "test_module.py" with the code

from scapy.all import *

and when i execute the file with python test_module.py the module is getting imported successfully but when I run the file using the command sudo python test_module.py it is saying the error

Traceback (most recent call last):
  File "test_module.py", line 1, in <module>
    from scapy.all import *
ImportError: No module named scapy.all

System info:-

Linux mint 20

Python 2.7.18

So, Please help me to fix this issue.

Upvotes: 1

Views: 557

Answers (2)

G&#252;nther
G&#252;nther

Reputation: 1

perhaps, try :

pip install scapy
import sys

# and take the correct Path to your scapy , example :

sys.path.insert(1, '/home/Your NAME/anaconda3/lib/python3.8/site-packages/')

Upvotes: -1

Cukic0d
Cukic0d

Reputation: 5411

Did you do

sudo python -m pip install scapy

first ? your issue is likely just having two separate environments

Upvotes: 2

Related Questions