DRV8835 raspberry pi 2 B+

Not a hardware issue. When I run the example code I get import error: “no module named wiringpi2”

Any insite on why this is happening? Any other information I need to provide in order to get this fixed?

I fallowed the directions exactly on how to install the DRV8835 library from github.

Hello, Loren.

From the error you are getting, it sounds like the WiringPi2-Python library might not have installed correctly. Can you try re-entering the commands for downloading and installing WiringPi2-Python listed in the “Installation” section of the Python library for the DRV8835 Dual Motor Driver Kit for Raspberry Pi GitHub page? Can you post a copy of the output you get when you run those commands?


HI BrandonM

Here are the steps exactly as I performed them after removing
wiringpi and wiringpi2-Python folders.

  1. open terminal.

  2. entered “sudo apt-get install git”

  3. git was already newest version.

  4. entered “git clone git://git.drogon.net/wiringPi”

  5. terminal put out:
    Cloning into ‘wiringPi’…
    remote: Counting objects: 1009, done.
    remote: Compressing objects: 100% (831/831), done.
    remote: Total 1009 (delta 715), reused 214 (delta 142)
    Receiving objects: 100% (1009/1009), 327.76 KiB | 0 bytes/s, done.
    Resolving deltas: 100% (715/715), done.
    Checking connectivity… done.

  6. Entered “cd wiringPi”

  7. Terminal changed directory

  8. Entered ./build

  9. Terminal did stuff then said All done.

  10. Terminal also made this note:

NOTE: To compile programs with wiringPi, you need to add:
to your compile line(s) To use the Gertboard, MaxDetect, etc.
code (the devLib), you need to also add:
to your compile line(s).

I then closed out terminal.

Then I moved to the next step of downloading and installing wiringpi 2

  1. Open terminal
  2. Entered: git clone https://github.com/Gadgetoid/WiringPi2-Python.git
  3. Entered: cd WiringPi2-Python
  4. Entered: sudo apt-get install python-dev python-setuptools
  5. Terminal did a bunch of stuff then said it needed to get 18.2mb of archives
    and that it needed 25.7mb of additional space to be used (I have a 32gb card with plenty of space)
  6. Terminal asks: "Do you want to continue? [Y/n]
  7. Enter: y
  8. Terminal does stuff…
  9. Finally after that’s done enter: sudo python setup.py install
  10. Terminal does a bunch more stuff.
  11. When it’s done it tells me where it installed to and that the version of wiringpi2 is 1.1.1

Close terminal.

Finally last steps:

  1. Open terminal
  2. enter: git clone https://github.com/pololu/drv8835-motor-driver-rpi.git
  3. enter: cd drv8835-motor-driver-rpi
  4. enter: sudo python setup.py install
  5. Terminal does stuff and writes the drv library to /usr/local/lib/python2.7 etc…

Close out terminal

Steps taken to try running the example program:

  1. Open terminal

  2. Enter: cd /home/pi/drv8835-motor-driver-rpi

  3. Enter: ls

  4. Terminal outputs:
    build example.py pololu_drv8835_rpi.py README.textile setup.py

  5. Enter sudo python example.py

AND dang it.

lol it worked.

I think my frustration was trying to get this to go in python3 which is what I learned on.

So I guess I’ll just figure out the difference between the 2 and program this in python 2.

Unless you could point out what I need to do differently to install this stuff for python 3.

I am glad it is working for you now; thank you for letting me know.

The “Installation” section of the GitHub page for the library (that I linked to in my first post) has instructions for different versions of Python:


Ok I re-removed the files as I really want this to work in python 3.

Here are the steps I took to try to install it for python 3:

  1. open terminal
  2. Enter: git clone git://git.drogon.net/wiringPi
  3. Enter: cd wiringPi
  4. Enter: ./build
  5. Quit terminal


  1. open terminal
  2. Enter: git clone https://github.com/Gadgetoid/WiringPi2-Python.git
  3. Enter: cd WiringPi2-Python
  4. Enter: sudo apt-get install python3-dev python3-setuptools
  5. Terminal: python3-setuptools and dev are already newest version
  6. Enter: sudo python3 setup.py install
  7. Quit terminal


  1. open terminal
  2. Enter: git clone https://github.com/pololu/drv8835-motor-driver-rpi.git
  3. Enter: cd drv8835-motor-driver-rpi
  4. Enter: sudo python3 setup.py install
  5. quit terminal


  1. open terminal

  2. Enter: cd /home/pi/drv8835-motor-driver-rpi

  3. Enter: sudo python3 example.py

  4. Terminal:

    Traceback (most recent call last):
    File “example.py”, line 3, in
    from pololu_drv8835_rpi import motors, MAX_SPEED
    File “/home/pi/drv8835-motor-driver-rpi/pololu_drv8835_rpi.py”, line 1, in
    import wiringpi2
    File “/usr/local/lib/python3.4/dist-packages/wiringpi2-1.1.1-py3.4-linux-armv7l.egg/wiringpi2.py”, line 28, in
    _wiringpi2 = swig_import_helper()
    File “/usr/local/lib/python3.4/dist-packages/wiringpi2-1.1.1-py3.4-linux-armv7l.egg/wiringpi2.py”, line 24, in swig_import_helper
    _mod = imp.load_module(’_wiringpi2’, fp, pathname, description)
    File “/usr/lib/python3.4/imp.py”, line 243, in load_module
    return load_dynamic(name, filename, file)
    ImportError: /usr/local/lib/python3.4/dist-packages/wiringpi2-1.1.1-py3.4-linux-armv7l.egg/_wiringpi2.cpython-34m.so: undefined symbol: PyString_FromStringAndSize

Last thing: entering “sudo python example.py” will still run the example. However doesn’t this mean I’m still running it in python 2?


Yes, on Raspbian and other Debian-based systems, the command python usually corresponds to Python 2. You can check this by running python --version. So if you run sudo python example.py, you are still using Python 2.

I looked into the error you were getting and it turned out that it was a bug in the WiringPi2-Python repository, and that repository is deprecated. We just published a new version of the drv8835-motor-driver-rpi library which fixes this problem, and it has simpler instructions that should work with both Python 2 and Python 3. Please try the new instructions and let me know if you have any issues.


I just wanted to thank you for successfully helping me fix this. Both python 2 and 3 will now run the example so I can finally get to programming now. :grinning:

1 Like