I have looked for similar solutions here however the only ones I can find do not fix the problem, and the solutions like this one python module 'serial' has no attribute 'Serial' [duplicate] does not get solved.
This code
self.ser = serial.Serial(port=self.dev_path, baudrate=600, bytesize=8, parity='N', stopbits=1, timeout=None)
is giving the error
AttributeError: module 'serial' has no attribute 'Serial'
I am importing serial as
import serial
However other solutions suggest using
from serial import Serial
it gives the error
NameError: name 'serial' is not defined
Edit Full Code:
def __init__(self, debugging=False):
# self.ser = serial.Serial(port='/dev/ttyUSB0',baudrate=600, bytesize=8, parity='N', stopbits=1, timeout=None)
self.ser = serial.Serial(port=self.dev_path, baudrate=600, bytesize=8, parity='N', stopbits=1, timeout=None)
print(str(self.ser.name))
self.status()
self.debug = debugging
if (self.debug):
print(self.ser.name)
print("Pulse: " + str(self.pulse) + "\n")
def __del__(self):
self.ser.close()