title: Python 2.7 serial ubuntu
body: <p>I reinstalled and changed OS from Debian8 to Ubuntu18.04, and have troubles with manage Serial(USB) ports via Python2.7.</p>
  
  <p>My steps are:</p>
  
  <pre><code>sudo apt-get install python-serial
  
  pip install pyserial
  Requirement already satisfied: pyserial in ./venv/lib/python2.7/site-packages (3.4)
  
  # usermod -a -G dialout wiks
  $ getent group dialout
  dialout:x:20:wiks
  </code></pre>
  
  <p>piece of code:</p>
  
  <pre><code>    for port in ports_list:
          try:
              s = serial.Serial(port,
                                timeout=1.0)
              s.close()
              result.append(port)
          # except (OSError, serial.SerialException):
          #     log_at.debug('problem with %s ', unicode(port))
          except Exception, e:
              log_at.debug('problem with %s --&gt; %s [USER: %s ]', unicode(port), e, get_username())
  </code></pre>
  
  <p>but when I start script it give me:</p>
  
  <pre><code>2018-12-31 12:42:51.536  DEBUG     at               all in OS ports: ['/dev/ttyUSB6', '/dev/ttyUSB5', '/dev/ttyUSB4', '/dev/ttyUSB3', '/dev/ttyUSB2', '/dev/ttyUSB1', '/dev/ttyUSB0', '/dev/ttyprintk', '/dev/ttyS4', '/dev/ttyS31', '/dev/ttyS30', '/dev/ttyS29', '/dev/ttyS28', '/dev/ttyS27', '/dev/ttyS26', '/dev/ttyS25', '/dev/ttyS24', '/dev/ttyS23', '/dev/ttyS22', '/dev/ttyS21', '/dev/ttyS20', '/dev/ttyS19', '/dev/ttyS18', '/dev/ttyS17', '/dev/ttyS16', '/dev/ttyS15', '/dev/ttyS14', '/dev/ttyS13', '/dev/ttyS12', '/dev/ttyS11', '/dev/ttyS10', '/dev/ttyS9', '/dev/ttyS8', '/dev/ttyS7', '/dev/ttyS6', '/dev/ttyS5', '/dev/ttyS3', '/dev/ttyS2', '/dev/ttyS1', '/dev/ttyS0']
  2018-12-31 12:42:51.536  DEBUG     at               problem with /dev/ttyUSB6 --&gt; 'module' object has no attribute 'Serial' [USER: wiks ]
  2018-12-31 12:42:51.536  DEBUG     at               problem with /dev/ttyUSB5 --&gt; 'module' object has no attribute 'Serial' [USER: wiks ]
  ...
  </code></pre>
  
  <p>or even:</p>
  
  <pre><code>File "/home/wiks/Dokumenty/projects/sms/sms/find_serial.py", line 73, in serial_ports
  except (OSError, serial.SerialException):
  AttributeError: 'module' object has no attribute 'SerialException'
  </code></pre>
  
  <p>...when I try to catch <strong>serial.SerialException</strong> </p>
  
  <p>I have no Idea, anybody helps? </p>
  
  <p>And ...is there way to avoid <strong># usermod -a -G dialout wiks</strong> before first start?</p>