Permission issue when using scapy - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Permission issue when using scapy (/thread-36293.html) |
Permission issue when using scapy - jao - Feb-05-2022 Hello, I'm learning the Scapy tool and right from the start I'm having a problem i can't solve Here's the Python code: from scapy.all import sr1, IP, ICMP p = sr1(IP(src = '8.8.8.8')/ICMP()) p.show()A permission error is returned: With this, I executed the script with sudo sudo python3 script.py and an import error was posted: Why does this happen? Does this problem have a solution?Environment OS: Linux Mint 20.2 x86_64 Scapy 2.4.5 Python 3.8.10 I'm using virtualenv so that script frameworks don't mix with s.o. RE: Permission issue when using scapy - snippsat - Feb-05-2022 Try -E switch to preserve environment. sudo -E python script_name.py (Feb-05-2022, 02:53 PM)jao Wrote: Why does this happen? Does this problem have a solution?The problem is that the package scapy has been installed as user and not as root. When you try to use sudo,it does not recognize the system path. So need sudo install to,or try make a virtual environment(build into Python) and run scapy from there. RE: Permission issue when using scapy - jao - Feb-05-2022 (Feb-05-2022, 03:14 PM)snippsat Wrote: Try -E switch to preserve environment. It worked, thank you . If I had installed Scapy with sudo pip3 install scapy i would still have the same problem?I intend to create an executable with this script for it to work on other computers, will it be necessary to run this script with root permission? RE: Permission issue when using scapy - snippsat - Feb-05-2022 (Feb-05-2022, 03:30 PM)jao Wrote: If I had installed Scapy with sudo pip3 install scapy i would still have the same problem?It should work when do this. Quote:I intend to create an executable with this script for it to work on other computers, will it be necessary to run this script with root permission?Yes scapy accesses the raw socket on OS,so the will need same root/sudo acess when run the code. |