Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm using Raspberry PI for my robotic project. I got this error when try run this code into my raspberry PI through terminal.
#servo_example.py
import servo
servo.servo_setup()
#0 - 180 degrees only!
servo.servo_set_deg(145)
servo.servo_cleanup()
Error message
Traceback (most recent call last):
File "servo_example.py", line 2, in <module>
import servo
ImportError: No module named servo
Why I got this error message? How I can fix it?
–
You have named your script servo.py
. This means that when you import servo
, you are importing your own script. It doesn't have a function named servo_setup
so you get an error. You can't import the system's servo.py
while your own script is named servo.py
. Solution: name your script something else.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.