0

I'm with problem with compile this file in Python, I tried to use Python 2 ou 3, but it persist with this error.

When o type python3.4 ServoMotor.py it returns me

# python3.4 ServoMotor.py
Traceback (most recent call last):
File "ServoMotor.py", line 1, in <module>
 from tkinter import *
  File "/usr/local/lib/python3.4/tkinter/__init__.py", line 38, in <module>
   import _tkinter # If this fails your Python may not be configured for Tk
  ImportError: No module named '_tkinter'

see below the file ServoMotor.py

 from tkinter import *
 import RPi.GPIO as GPIO
 import time

 GPIO.setwarnings(0)
 GPIO.setmode(GPIO.BCM)
 GPIO.setup(18, GPIO.OUT)
 pwm = GPIO.PWM(18, 100)
 pwm.start(5)

 class App:

 def __init__(self, master):
     frame = Frame(master)
     frame.pack()
     scale = Scale(frame, from_=0, to=180,orient=HORIZONTAL, command=self.update)
     scale.grid(row=0)

 def update(self, angle):
     duty = float(angle) / 10.0 + 2.5
     pwm.ChangeDutyCycle(duty)


 root = Tk()
 app = App(root)
 root.wm_title('Servo Control')
 root.geometry("200x150+0+0")
 root.mainloop()

What can I fix it?

Thanks in advanced.

1
  • 1
    Same question has already been answered on askubuntu
    – Jacobm001
    Mar 3, 2016 at 2:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.