find a solution about run python program getting error simple program

import serial 
ser =serial.serial ("dev/ttyAMA0",baudrate = 9600) 

error attributeerror 'module' object has no attribute 'serial'

Capitalisation is important. You want serial.Serial() instead of serial.serial()

You've also not put the correct path to the serial device - dev/ttyAMA0 would be relative to the place the user runs the script from (so would only work if you run it from /).

Your code should be:

import serial
ser = serial.Serial("/dev/ttyAMA0", baudrate=9600) 

See http://www.elinux.org/Serial_port_programming for more examples.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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