So, I am trying to use my RPi model 2B to control a DC motor with an l293d controller. I have moved onto the python3 script and imported the 'l293d' module. Here is my code...

import l293d.driver as l293d
motor1 = l293d.motor(22,18,16)
for i in range(200):

and the error that it returns is...

AttributeError: module 'l293.driver' has no attribute 'motor'

Can someone please explain why this error is occurring. Thanks.

  • Not Pi specific. The message is quite explicit. module 'l293.driver' has no attribute 'motor'. That means there is nothing called motor in the module l293d.driver (whatever that is).
    – joan
    Commented Aug 6, 2018 at 20:51
  • Did you create a file named l283d.py yourself? That would confuse Python
    – Dirk
    Commented Aug 6, 2018 at 20:59
  • No, the file is called 'motor.py', but it is in python3. Is this a module for python2 only?
    – jdw136
    Commented Aug 6, 2018 at 21:01

2 Answers 2


If you read the documentation, there are two mistakes in your code. First, just use import l293d. Second, use motor1 = l293d.DC(22, 18, 16)

There isn't a motor attribute, but there is a DC attribute for DC motors.

This runs on my system.

jay@gotham:~/python$ python3 test.py
[l293d]: Can't import RPi.GPIO; test mode has been enabled:
[l293d]: spinning clockwise motor at BOARD pins [22, 18 and 16]
[l293d]: spinning clockwise motor at BOARD pins [22, 18 and 16]

(... Many repetitions of the above line removed ...)

[l293d]: Cleanup not needed when test_mode is enabled.

According to documentation page for the l293d Python library, you've used syntax that's incorrect. The docs suggest this may work:

import l293d  
motor1 = l293d.DC(22, 18, 16)  

then the rest of your code.

  • @NomadMaker called out a mistake in my answer; +1 for him :) I'm going to edit my answer just to eliminate a potential source of confusion.
    – Seamus
    Commented Aug 7, 2018 at 1:58

Your Answer

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

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