Python脚本找不到模块

Sil*_*ows 1 module importerror python-3.x raspberry-pi wiringpi

我是编程世界的新手,我想用这段代码来移动一个小舵机:

# Servo Control
# Servo Control
import time
import wiringpi

# use 'GPIO naming'
wiringpi.wiringPiSetupGpio()

# set #18 to be a PWM output
wiringpi.pinMode(18, wiringpi.GPIO.PWM_OUTPUT)

# set the PWM mode to milliseconds stype
wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)

# divide down clock
wiringpi.pwmSetClock(192)
wiringpi.pwmSetRange(2000)

delay_period = 0.01

while True:
        for pulse in range(50, 250, 1):
                wiringpi.pwmWrite(18, pulse)
                time.sleep(delay_period)
        for pulse in range(250, 50, -1):
                wiringpi.pwmWrite(18, pulse)
                time.sleep(delay_period)
Run Code Online (Sandbox Code Playgroud)

当我在空闲状态下运行这段代码时,出现以下错误:

Traceback (most recent call last):
  File "/home/pi/servo.py", line 3, in <module>
    import wiringpi
ImportError: No module named 'wiringpi'
Run Code Online (Sandbox Code Playgroud)

我确实安装了wiringpi。我使用以下方法检查了它:

dpkg --get-selections
Run Code Online (Sandbox Code Playgroud)

我在以下时间之间找到了它:

wireless-regdb
wireless-tools
wiringpi
wolfram-engine
wolframscript   
Run Code Online (Sandbox Code Playgroud)

请帮忙帮忙,谢谢

AND*_*NEZ 5

只需更改为sudo pip3 install Wiringpi。发生这种情况是因为 python 解释器是 V2.7