Following the DroneKit instructions, I was able to run the hello.py code from their QuickStart guide: http://python.dronekit.io/guide/quick_start.html.
However, when I try to run their basic mission example, I get the setBaudrate error in the title:
$ python mission_basic.py --connect=/dev/tty.usbmodem1411
Connecting to vehicle on: /dev/tty.usbmodem1411
Traceback (most recent call last):
File "mission_basic.py", line 23, in <module>
vehicle = connect(args.connect, wait_ready=True)
File "/Library/Python/2.7/site-packages/dronekit/__init__.py", line 2344, in connect
handler = MAVConnection(ip, baud=baud, source_system=source_system)
File "/Library/Python/2.7/site-packages/dronekit/mavlink.py", line 37, in __init__
self.master = mavutil.mavlink_connection(ip, baud=baud, source_system=source_system)
File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 1106, in mavlink_connection
return mavserial(device, baud=baud, source_system=source_system, autoreconnect=autoreconnect, use_native=use_native)
File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 735, in __init__
self.set_baudrate(self.baud)
File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 746, in set_baudrate
self.port.setBaudrate(baudrate)
AttributeError: 'Serial' object has no attribute 'setBaudrate'
Note: tty.usbmodem1411 is my USB cable running straight from my Mac running Yosemite to the APM. I have also tried with the 3DR telemetry kit with the same results. I have also tried adding in the baud rate option with the same result.
UPDATE: Using the link's patch that 陳昭宇 gave resolved my baud rate issue; however, I still had an issue with never finding a heartbeat. This issue was also because of the pyserial update. Using the older pyserial solution that Tim Ryan provided fixed both problems.
Fin, it looks like pySerial 3.0 was released in the past week which changes its API. pymavlink (used by DroneKit-Python) requires pySerial 2.0. I've filed an issue and will work to resolve it.
In the meantime, try pip install "pySerial>=2.0,<=2.9999"
and see if this resolves your problem.