Python Attributeerror: 'Module' Object Has No Attribute 'Serial'

Python AttributeError: 'module' object has no attribute 'Serial'

You're importing the module, not the class. So, you must write:

from serial import Serial

You need to install serial module correctly: pip install pyserial.

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

Looking at the documentation it looks like you only need to do

import serial

instead of

from serial import serial

http://pyserial.readthedocs.io/en/latest/shortintro.html

Python attributeError: module 'serial' has no attribute 'Serial'

Hah!

the problem was my filename. I was using same file name with my python package!

I changed my filename from serial.py to test.py and it start working.

Python - module 'serial' has no attribute 'Serial'

This is the code that worked for me

import serial

ser = serial.Serial('COM14', baudrate = 9600, timeout = 1)

def getValues():

ser.write(b'rf')
arduinoData = ser.readline().decode('ascii')
return arduinoData

while(1):

userInput = input('Get data point?')

if userInput == 'y':
print(getValues())


Related Topics



Leave a reply



Submit