Import error in Python 3.6 with sudo?

自作多情 提交于 2019-12-11 17:24:53

问题


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


回答1:


As using python3, I would recommend

sudo python3 -m pip install scapy

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




回答2:


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.



来源:https://stackoverflow.com/questions/51909250/import-error-in-python-3-6-with-sudo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!