Start using odrive with python

Hey guys, I just get started with odrive.

When I run the simplest program to test, it shows AttributeError: module ‘odrive’ has no attribute ‘find_any’ Does anyone know how to fix it?

I’m using Anaconda3 in Windows 8.1. I’ve already installed the odrive library ( pip install odrive ), and there is no problem with connection since I can see it is connected in odrivetool.

Your file that you’re running is also called I think it’s trying to import itself, and finds that it doesn’t have a find_any() method in it. Rename your file to anything else (maybe ‘’) and you’ll be fine.

Thanks Josh! So stupid I am:joy:

It stops warning. But the new thing is nothing will happen after running this script. It should print something I guess but there it not. Could you please help me further with it?

Thanks again.

I would recommend playing around interactively to get a feel for what functionality is available. In PyCharm, open up a Python console, which should launch iPython (or just the python REPL if you don’t have iPython installed in your environment). Then try things like:

import odrive

od = odrive.find_any()
axis = od.axis0
mo = axis.motor
enc = axis.encoder

If you execute these lines one at a time in the python console, you’ll see the output from each one. The ODrive, Axis, Motor and Encoder objects all print out some nice information to the console.


Hi Josh, thank you for helping me out!

Your method works. It looks cool!

I am also curious how do you usually work with odrive? Always execute the commands line by line, but not write all things you want to do in a single script and run it at one time?

If I’m just trying to get something working, I tend to explore by running it interactively. Once I get an idea of how to accomplish a smaller part of the larger task, I’ll put that into a script and keep going from there.

Also note that when you are running a script in PyCharm, there is an option in the Run configuration dialog to ‘Run with Python console,’ which will leave the REPL (the interactive interpreter) still running after the script has finished, allowing you continue interacting with it.


I had a question about the find_any() command. Mainly how you found it. I’m also just about to start using python scripts with the odrive and was wondering if there was definitive list of commands for the Odrive pre-installed firmware?

Like how did you know about find_any()? I did not see it on the documents page but it seems imperative to work outside of the odrivetool.


Mostly I started by reading through the documentation, starting with the main Getting Started page. Towards the bottom of that page, there’s a section with links for other stuff to read, including some basic docs about the various control interfaces available.

On that page, there’s a section with details about the native Python protocol, that has some good pointers about getting started w/ Python, including the find_any() method.

Finally, that section has a link to the code on the GitHub repo, which shows a lot of the basics of getting going with Python control.

(I think I also poked around in the code for odrivetool when I first started playing around with the ODrive board.)

All that said, it does seem like it would be a good idea to maybe link to the file on the main Getting Started page of the docs. I can see how you might not have found that file right off the bat.

Hope this helps!

1 Like

Thanks a lot. That’s a great help.

Hi valoi, I have the same question as you did. I didn’t find any library contains these odrive functions. As I wanna invoke these functions but I don’t even know the API name. Have you find something yet?

Maybe I know how it works for users not developers. I can just use those commands like “odrv0.axis0.requested_state = 8” run it then the odrive will follow this command. It’s just like function overloading on ‘=’. It looks like Python is very convenient and powerful.