Avatar of Rama Tito
Rama Tito
Flag for Malaysia

asked on 

AttributeError: module 'serial' has no attribute 'Serial'

good day, I am testing serial port communciation on raspberry pi 3 interface with SIM 900 module. The code are attached with error message. Thanks

import serial
import os, time
 
# Enable Serial Communication
port = serial.Serial("/dev/ttyS0", baudrate=38400, timeout=1)
 
# Transmitting AT Commands to the Modem
# '\r\n' indicates the Enter key
 
port.write('AT'+'\r\n')
rcv = port.read(10)
print (rcv)

>>> 
======================== RESTART: /home/pi/SIM900.py ========================
Traceback (most recent call last):
  File "/home/pi/SIM900.py", line 1, in <module>
    import serial
  File "/home/pi/serial.py", line 5, in <module>
    port = serial.Serial("/dev/ttyS0", baudrate=38400, timeout=1)
AttributeError: module 'serial' has no attribute 'Serial'
>>>
PythonRaspberry Pi

Avatar of undefined
Last Comment
Rama Tito

8/22/2022 - Mon