使用sudo在Python 3.6中导入错误? [英] Import error in Python 3.6 with sudo?
本文介绍了使用sudo在Python 3.6中导入错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一个使用Scapy
的程序. Python
能够完美地导入scapy
模块,但是使用scapy
的sniff
功能需要以管理员身份运行该程序.
但是,以sudo python3 <program_name>
身份运行程序会生成import error
,为什么会这样?
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?
这是导入行:import scapy.all as scapy
推荐答案
就像使用python3一样,我建议
As using python3, I would recommend
sudo python3 -m pip install scapy
当然,pyenv也可以使用.
Of course pyenv works too I'd you're familiar with it.
这篇关于使用sudo在Python 3.6中导入错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文