# Arduino IDE to Python- problems with the Firmata library

**URL:** <https://forum.arduino.cc/t/arduino-ide-to-python-problems-with-the-firmata-library/1288752>\
**Category:** Programming\
**Created:** [August 5, 2024, 3:47pm UTC](https://forum.arduino.cc/t/arduino-ide-to-python-problems-with-the-firmata-library/1288752 "2024-08-05T15:47:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bassoon30](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bassoon30/32/1061787_2.png) [@bassoon30](https://forum.arduino.cc/u/bassoon30)\
**Post date:** [August 5, 2024, 3:47pm UTC](https://forum.arduino.cc/t/arduino-ide-to-python-problems-with-the-firmata-library/1288752/1 "2024-08-05T15:47:06Z")

</div>

Hello there! I am trying to create a simple blinking LED in python. I am using the firmata library in Arduino IDE and PyCharm to code the LED. First, I installed the firmata library in Arduino IDE and then uploaded the standard example to my Arduino Mega 2560. That worked fine, but when I switched over to pyCharm with the code below, I got the following errors.

```arduino
from pyfirmata import Arduino
import time
board = Arduino('COM3')

led = board.get_pin(13)
while True:
    led.write(True)
    time.sleep(1)
    led.write(False)
    time.sleep(1)

```

Errors:

```arduino
Traceback (most recent call last):
  File "C:\Users\rajik\PycharmProjects\pineapple\mini_projects\von_mysteriouso.py", line 16, in <module>
    board = Arduino('COM3')
            ^^^^^^^^^^^^^^^
  File "C:\Users\rajik\PycharmProjects\pineapple\.venv\Lib\site-packages\pyfirmata\ __init__.py", line 19, in __init__
    super(Arduino, self). __init__ (*args, **kwargs)
  File "C:\Users\rajik\PycharmProjects\pineapple\.venv\Lib\site-packages\pyfirmata\pyfirmata.py", line 101, in __init__
    self.setup_layout(layout)
  File "C:\Users\rajik\PycharmProjects\pineapple\.venv\Lib\site-packages\pyfirmata\pyfirmata.py", line 157, in setup_layout
    self._set_default_handlers()
  File "C:\Users\rajik\PycharmProjects\pineapple\.venv\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\rajik\PycharmProjects\pineapple\.venv\Lib\site-packages\pyfirmata\pyfirmata.py", line 185, in add_cmd_handler
    len_args = len(inspect.getargspec(func)[0])
                   ^^^^^^^^^^^^^^^^^^

```

Is this a problem regarding how I downloaded the firmata library, or is it my code?

Thank you!!! 😁

---

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [August 5, 2024, 4:39pm UTC](https://forum.arduino.cc/t/arduino-ide-to-python-problems-with-the-firmata-library/1288752/2 "2024-08-05T16:39:31Z")

</div>

> [@bassoon30](#):
>
> ```arduino
> File "C:\Users\rajik\PycharmProjects\pineapple\.venv\Lib\site-packages\pyfirmata\pyfirmata.py", line 185, in add_cmd_handler
> len_args = len(inspect.getargspec(func)[0])
> 
> ```

The error you encountered stems from the use of deprecated functions in the `inspect` module of Python, which causes incompatibility with recent versions of Python and the `pyFirmata` library.

Specifically here, `inspect.getargspec()` has been deprecated since Python 3.5 (it was removed in Python 3.11).

if the `pyFirmata` library still references this function then it's an issue...

One option would be to downgrade your Python version to 3.10 or earlier

Alternatively you could consider using another library like [`PyMata`](https://pypi.org/project/PyMata/) or[`pyFirmata2`](https://pypi.org/project/pyFirmata2/), which should be compatible with newer versions of Python.

(I don't use pyFirmata so I can't really recommend one. If you were willing to develop your own Arduino code and your own python code and get rid of the pyFirmata constraints, I've written a small tutorial on interfacing with Python. See [Two ways communication between Python3 and Arduino](https://forum.arduino.cc/t/two-ways-communication-between-python3-and-arduino/1219738) )

---

<div class="post-metadata">

**Author:** ![bassoon30](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bassoon30/32/1061787_2.png) [@bassoon30](https://forum.arduino.cc/u/bassoon30)\
**Post date:** [August 6, 2024, 8:59pm UTC](https://forum.arduino.cc/t/arduino-ide-to-python-problems-with-the-firmata-library/1288752/3 "2024-08-06T20:59:41Z")

</div>

Thank you so much!!! PyFirmata2 worked! 😁😁😁

---

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [August 6, 2024, 9:10pm UTC](https://forum.arduino.cc/t/arduino-ide-to-python-problems-with-the-firmata-library/1288752/4 "2024-08-06T21:10:41Z")

</div>

Good to hear

Have fun

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [February 2, 2025, 9:10pm UTC](https://forum.arduino.cc/t/arduino-ide-to-python-problems-with-the-firmata-library/1288752/5 "2025-02-02T21:10:42Z")

</div>

Closed on February 2, 2025, 9:10pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
