Hi i am trying to make a comunication between theses device but when i am trying to run in my raspberry i have the follow error:

Traceback (most recent call last): File "serial.py", line 1, in import serial File "/home/pi/Desktop/serial.py", line 2, in ser = serial.Serial('/dev/ttyACM0', 9600) AttributeError: 'module' object has no attribute 'Serial'

i have the next code:

import serial

ser = serial.Serial('/dev/ttyACM0', 9600)

while 1:

    if(ser.in_waiting >0):
        line = ser.readline()

If any can help me, i will be thankfull

  • did you check if a function nsmed Serial actually exists in the serial library?
    – jsotola
    Commented Jun 16, 2019 at 16:52
  • Don't name your files with the names of modules you're using. Also, why ask a Raspberry question on Arduino site when we have RPi.SE, where the exact same question was already answered? Commented Jun 18, 2019 at 7:45

1 Answer 1


What's almost certainly happening here is that you've named your file serial.py, so the import is trying to load the library from your file within the current working directory.

To fix this problem, simply rename your serial.py script to something else, for example serial_comms.py or whatever other useful name you want.

  • you are a genius, that was the problem thank you Commented Jun 16, 2019 at 17:06
  • @JesusMiguelHerrera You're most welcome. I ran into this when I had to learn Python for a previous job.
    – stevieb
    Commented Jun 16, 2019 at 17:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.