Pyfirmata throws error after creating arduino object


I’m trying to start an arduino project but every time I try running it it throws an error. I think I might have gotten some of the setup wrong?

I’ve uploaded the Standard Firmata Sketch to the Arduino Mega and installed pyFirmata. I can’t really think of what else I could’ve done wrong.

Note that I’d already tried in another computer and, while it didn’t really work, the board was initialized and it didn’t throw any error like this

This is my python code

import pyfirmata as pf

board = pf.ArduinoMega('COM5')

And this is the eror thrown

Traceback (most recent call last):
  File "C:UsersstikyDesktopCodePython", line 3, in <module>
    board = pf.ArduinoMega('COM5')
  File "", line 32, in __init__
    super(ArduinoMega, self).__init__(*args, **kwargs)
  File "", line 101, in __init__
  File "", line 157, in setup_layout
  File "", line 161, in _set_default_handlers
    self.add_cmd_handler(ANALOG_MESSAGE, self._handle_analog_message)
  File "", line 185, in add_cmd_handler
    len_args = len(inspect.getargspec(func)[0])
AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?

What am I doing wrong?

Asked By: Sumito



This is probably a compatibility issue between PyFirmata and your Python version.

getargspec is deprecated since Python 3.11.

An up-to-date PyFirmata version should have replaced this by getfullargspec.

Also the PyFirmata documentations says

It runs on Python 2.7, 3.6 and 3.7.

So I would not necessarily expect 3.11 to run without problems.

Answered By: Piglet