'serial' has no attribute 'serialException'

I used following sketch to connect my NEO 6M GPS module to laptop.

import serial

try:
    gps = serial.Serial('com4',9600)
    while True:
        ser_bytes = gps.readline()
        decoded_data = ser_bytes.decode("utf-8")
        data = decoded_data.split(",")
        print(data)
except serial.serialException:
    print("Error")

In this case I used my Arduino NANO as USB to serial converter (No code uploaded toArduino and not used Arduino IDE when using Pycharm). I used correct com port and burd rate but following error code is showing.

AttributeError: module ‘serial’ has no attribute ‘serialException’

I had imported serial interpreter to this project. So how to solve this problem. Please give me tour ideas because I’m very new to python.
Thank You.

Hello, @Indula, and welcome to Python Software Foundation Discourse!

Python is case-sensitive. You need to be looking for a serial.SerialException.

EDIT:

After you correct that line, and execute the code again, you may see the following displayed in the output, and then would need to continue to diagnose the problem:

Error
3 Likes

Thank You.

By Indula_Karunathilaka via Discussions on Python.org at 09Jul2022 11:22:

I used following sketch to connect my NEO 6M GPS module to laptop.

except serial.serialException:
   print("Error")

The case sensitivity has been mentioned. I just wanted to comment on
this bit. You should write something like this:

except serial.serialException as e:
    print("Error", e)

which will include the specific details from the exception. Throwing
that information away is usually unhelpful :slight_smile:

Cheers,
Cameron Simpson cs@cskk.id.au

2 Likes

Thank You @cameron It was really Useful.

I uninstalled pyserial and reinstall again. Then it will be works. Try it if you have facing same problem.