Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1251

Python • serial.Serial no longer works correct

$
0
0
Hello, the expression serial.Serial no longer works for me.
import serial
import time

ser = serial.Serial('/dev/ttyUSB0',9600)
A = "255\r"
ser.write(bytes(A, 'utf-8'))
print ("ALL RELAIS: ON!")
time.sleep(10)
B = "0\r"
ser.write(bytes(B, 'utf-8'))
print ("ALL RELAIS: OFF!")
ser.close()

After starting the programme, the following error is displayed
AttributeError: module ‘serial’ has no attribute ‘Serial’. Did you mean: ‘serial’?

https://stackoverflow.com/questions/411 ... ute-serial
Writes fixes the problem with:
pip3 uninstall serial
and
pip3 install pyserial

I have installed pip3: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

How can I replace the faulty serial file or is it another error?

Statistics: Posted by LoloLolo — Wed Oct 23, 2024 4:25 pm



Viewing all articles
Browse latest Browse all 1251

Trending Articles