[Python] ImportError: cannot import name 'Serial' from 'serial' (unknown location)

Discussão em 'Python' iniciado por Stack, Maio 23, 2025.

  1. Stack

    Stack Membro Participativo

    Whenever i execute the code below it gives me following Error:

    ImportError: cannot import name 'Serial' from 'serial' (unknown location)

    Code:


    from serial import Serial

    arduinodata = Serial('com4',9600)

    print("Enter n to ON LED and f to OFF LED")

    while 1:
    input_data = raw_input()
    print ("You Entered"+input_data)

    if (input_data == 'n'):
    arduinodata.write(b'1')
    print("LED ON")

    if (input_data == 'f'):
    arduinodata.write(b'0')
    print("LED OFF")


    I have installed all the required python modules. Like pyserial, pyfirmata etc but it is continuously giving me this error.

    Continue reading...

Compartilhe esta Página