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:\Users\stiky\Desktop\Code\Python Codes\Arduino\test.py", line 3, in <module>
board = pf.ArduinoMega('COM5')
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\stiky\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyfirmata\__init__.py", line 32, in __init__
super(ArduinoMega, self).__init__(*args, **kwargs)
File "C:\Users\stiky\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyfirmata\pyfirmata.py", line 101, in __init__
self.setup_layout(layout)
File "C:\Users\stiky\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyfirmata\pyfirmata.py", line 157, in setup_layout
self._set_default_handlers()
File "C:\Users\stiky\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyfirmata\pyfirmata.py", line 161, in _set_default_handlers
self.add_cmd_handler(ANALOG_MESSAGE, self._handle_analog_message)
File "C:\Users\stiky\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyfirmata\pyfirmata.py", 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?
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.
https://github.com/tino/pyFirmata/commit/1f6b116b80172e70c7866d595120413078ae1222
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.