Attribute error: Need solution

How to fix the following error:
module ‘serial’ has no attribute ‘Serial’

1 Like

“serial” is not a standard Python module:

>>> import serial
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'serial'

Are you sure that it is supposed to have a “Serial” attribute?

If it does, check your serial module:

import serial
print(dir(serial))

and see if it shows the attributes you are expecting. Check the path to
the file:

print(serial.__file__)

and see if it is the same as the serial module you are expecting. If
not, you have probably shadowed the original file. Don’t name your own
script the same as a module you need to import.

If your script is called “serial.py”, change the name to something else.

1 Like