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
Matplotlib Savefig() Plots Different from Show()
How to Do Assignments in a List Comprehension
Python: Best Way to Add to Sys.Path Relative to the Current Running Script
What Limitations Have Closures in Python Compared to Language X Closures
How to Loop Through All But the Last Item of a List
What's the Best Way to Generate a Uml Diagram from Python Source Code
Call Int() Function on Every List Element
Read from a Log File as It's Being Written Using Python
Pythonic Way to Check If a File Exists
What Is the Current Choice for Doing Rpc in Python
Redirecting Stdout to "Nothing" in Python
E731 Do Not Assign a Lambda Expression, Use a Def
How to Change the Range of the X-Axis with Datetimes in Matplotlib