title: 'serial' has no attribute Serial Error, not filename or import method
body: <p>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 <a href="https://stackoverflow.com/questions/47384676/python-module-serial-has-no-attribute-serial">python module 'serial' has no attribute 'Serial' [duplicate]</a> does not get solved.</p>
  
  <p>This code </p>
  
  <pre><code>self.ser = serial.Serial(port=self.dev_path, baudrate=600, bytesize=8, parity='N', stopbits=1, timeout=None)
  </code></pre>
  
  <p>is giving the error </p>
  
  <pre><code>AttributeError: module 'serial' has no attribute 'Serial'
  </code></pre>
  
  <p>I am importing serial as </p>
  
  <pre><code>import serial
  </code></pre>
  
  <p>However other solutions suggest using </p>
  
  <pre><code>from serial import Serial
  </code></pre>
  
  <p>it gives the error </p>
  
  <pre><code>NameError: name 'serial' is not defined
  </code></pre>
  
  <p>Edit Full Code:</p>
  
  <pre><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()
  </code></pre>