Scapy Module not found when running python script with SUDO
The PYTHON sys.path variable was different between regular and SUDO use (and SUDO is required for scapy module).
There were a couple different approaches I found to solve it: This ended up solving it with the .bashrc suggestion. Essentially, the python module paths needed to be added to the sudo user or environment. Good luck to anybody else who has this issue!
FeralShadow
Updated on September 18, 2022Comments
-
FeralShadow over 1 year
I have written a python script that uses
from scapy.all import *
and the sniff() function requires elevated privilege, so when I runpython3 scapyScript.py
I receive the errorPermissionError: [Errno 1] Operation not permitted
which makes sense.However, when I run
sudo python3 scapyScript.py
I receiveModuleNotFoundError: No module named 'scapy'
.I believe it's because I didn't install scapy using sudo access, but when I attempt to
sudo pip3 install scapy
it says there is no recognized command.I can't seem to find anything about this specifically, does anybody have any ideas?
I am using Debian 9.3.0-10 distro.
Thank you for your time.
-
K7AAY almost 4 yearsTo start with, which Linux distro have you installed (Ubuntu server, Ubuntu desktop, Kubuntu, Lubuntu, Xubuntu, Ubuntu MATE, Mint, et al.), & which release number? Different releases have different tools for us to recommend. Please click edit & add that to your question, so all facts we need are in the question. Please don't use Add Comment, since that's our one-way channel to you. All facts about your PC should go in the Question with edit as this is a Q&A site, not a general forum, so things work differently here.
-