1

I have a Adafruit PWM hat and I am trying to run play around with some servos. However, when I run this line:

from adafruit_servokit import ServoKit

It returns:

No module named 'adafruit_circuitpython_servokit'

I have already run:

pip3 install adafruit-circuitpython-servokit

After running the above command, it states that all requirements have been satisfied so it doesn't seem as though I am missing any module. Any ideas on what the issue could be?

16
  • Your program looks OK. I did the same and found no problem importing the servoKit thing. You might like to run my bare bone test program (debugged with sample output) to compare. penzu.com/p/46a4cc44
    – tlfong01
    Aug 4, 2019 at 14:25
  • Do you have more than one version of Python installed? (This is common and frustrating.) In that case, pip may have installed the package into a different version than the one that you are using.
    – Brick
    Aug 4, 2019 at 14:26
  • @Brick I have Python 2 and 3.7 installed. Since I used pip3 it should install to Python 3.7. Aug 4, 2019 at 14:36
  • @tlfong01 Sadly the error occurs as soon as the import statement is run :( Aug 4, 2019 at 14:37
  • 1
    @Richard Wessels, Many thanks for clarifying my mind.
    – tlfong01
    Aug 8, 2019 at 3:20

1 Answer 1

1

I installed the module as a normal user without sudo, so it was installed to that user's home directory and not the system. Running the script as root via sudo then meant that installation was not in the import path.

1
  • After reading servo hat tutorial, I know why mgpi84p44 suggests to sudo install python 3, to make sure even system default python 2, python 3 will install. However, Servokit should be installed in pi's /home/lib. Now of course you just use python3 myporg to run program, no sudo python3. (I only know very basic sudo, so only 80% sure.)
    – tlfong01
    Aug 8, 2019 at 3:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.