How can I solve this error?


I'm doing a program to control TVs remotely, but I get this error.

    Juans-MacBook-Pro:libLGTV_serial-master juanpablo$ python --togglepower
Traceback (most recent call last):
  File "", line 5, in <module>
    from libLGTV_serial import LGTV  File "/Users/juanpablo/Desktop/control tv/libLGTV_serial-master/", line 3, in <modul
    import serialImportError: No module named serial


# Sample Windows script which uses the libLGTV_serial library
# Can be called, for example by doing "python --poweroff"
import sys
from libLGTV_serial import LGTV

model = '43LV640S'                    # Change this to your TV's model

# Change this to the serial port you're using
# On Linux it might look like '/dev/ttyS0'
# On a Mac it might look like '/dev/tty.usbmodemfa2321'
serial_port = "802MXTCQ2353"

# Verify passed command
if len(sys.argv) != 2: 
    print('Usage: {0} <command>'.format(sys.argv[0]))
    print('Example: {0} --togglepower'.format(sys.argv[0]))

tv = LGTV(model, serial_port)

# Example of adding a custom toggle command. Passing in '--toggleinput'
# will toggle between 'inputrgbpc' and 'inputdigitalcable'
tv.add_toggle('input', 'inputrgbpc', 'inputdigitalcable')

# Sometimes a single remote button press is detected as many. By debouncing a
# command, we make sure its only called once per button press.

# Finally, send the command
# .send() Returns nothing on failure, 2-digit bytecode for status commands,
# and True for other commands
asked by JackNavaRow 17.12.2018 в 16:42

0 answers