Nerd001
Nerd001

Reputation: 171

Import error in Python 3.6 with sudo?

I have written a program that uses Scapy. Python is able to import the scapy module perfectly but using sniff function of scapy requires running the program as administrator. However, running the program as sudo python3 <program_name> produces an import error, why is it so?

Here is the import line : import scapy.all as scapy

Upvotes: 0

Views: 1174

Answers (2)

Cukic0d
Cukic0d

Reputation: 5421

As using python3, I would recommend

sudo python3 -m pip install scapy

Of course pyenv works too I'd you're familiar with it.

Upvotes: 3

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181390

You can fix it with:

$ sudo pip install scapy

And then try again.

I would recommend using virtualenv to run your program though. Instead of installing package after package in your main environment.

Upvotes: 1

Related Questions