'No module named 'pyfirmata'' error even though I have already installed pyfirmata using pip?

2.1k Views Asked by At

I started by uploading the StandardFirmata example from the Arduino IDE onto my Arduino UNO. I then successfully installed pyfirmata onto my windows pc using pip3 install pyfirmata to the path c:\users\ta319\anaconda3\lib\site-packages, however, when I try to run the following code in spyder:

#!/usr/bin/env python3

import pyfirmata
import time

if __name__ == '__main__':
    board = pyfirmata.Arduino('COM4 (Arduino UNO)')
    print("Communication Successfully started")
    
    while True:
        board.digital[13].write(1)
        time.sleep(1)
        board.digital[13].write(0)
        time.sleep(1)

I get this error:

Traceback (most recent call last):

File "C:\Users\ta319\AppData\Local\Programs\Spyder\pkgs\spyder_kernels\py3compat.py", line 356, in compat_exec exec(code, globals, locals)

File "c:\users\ta319\firmata setup.py", line 3, in import pyfirmata

ModuleNotFoundError: No module named 'pyfirmata'

Any suggestions would be greatly appreciated, thanks!

1

There are 1 best solutions below

2
On

You probably installed with pip and not pip3, try python3 -m pip install pyfirmata or pip3 install pyfirmata