Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入错误:没有名为ADAU电机的模块_Python_Raspberry Pi_Adafruit - Fatal编程技术网

Python 导入错误:没有名为ADAU电机的模块

Python 导入错误:没有名为ADAU电机的模块,python,raspberry-pi,adafruit,Python,Raspberry Pi,Adafruit,我刚刚安装了Adafruit MotorKit库,并创建了如下代码: from adafruit_motorkit import MotorKit kit = MotorKit() 但是,当我使用sudo命令sudo python motortest.py启动程序时,我发现: 导入错误:没有名为adafruit\u motorkit的模块 我不明白,因为我使用命令sudopip3installadafruit-pythonmotorkit遵循了库的安装过程 我从Raspberry Pi 3B+

我刚刚安装了Adafruit MotorKit库,并创建了如下代码:

from adafruit_motorkit import MotorKit
kit = MotorKit()
但是,当我使用sudo命令sudo python motortest.py启动程序时,我发现:

导入错误:没有名为adafruit\u motorkit的模块

我不明白,因为我使用命令sudopip3installadafruit-pythonmotorkit遵循了库的安装过程


我从Raspberry Pi 3B+上的raspbian桌面运行我的程序

您可以通过
pip3
安装模块,因此您需要使用
python3
运行脚本


类似这样:
sudo python3 motortest.py

您不应该以sudo的形式运行python脚本-您会得到这个错误,因为指令中说要使用sudo pip3安装它-如果您只运行pip3安装adafruit,python motorkit OP可以在没有sudo的情况下运行脚本