title: Python cannot access my usb device - insufficient permission
body: <p>Python script cannot send print to my usb Epson receipt printer</p>
  
  <p>I am new to Ubuntu. I am trying to send some text to a thermal label printer connected to my computer via usb. Upon executing the code in Visual Studio Code by pressing the F5 key, I get the below error</p>
  
  <pre><code>File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
  raise USBError(_strerror(ret), ret, _libusb_errno[ret])
  usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
  </code></pre>
  
  <p>However, if I execute the same code with:</p>
  
  <pre><code>sudo python3 -m test5.py
  </code></pre>
  
  <p>then, it prints out all right. I have done many google searches, and it seems that this is a problem related to my rule settings, so I made the following rule in /etc/udev/rules.d/printerRule.rules</p>
  
  <pre><code>SUBSYSTEM=="usb", ATTRS{idVendor}=="1208", ATTRS{idProduct}=="3605",  MODE="0666", OWNER="hdadmin"
  </code></pre>
  
  <p>Still the problem persists. </p>
  
  <p>The reason why I need to solve this problem is, I later need to compile the Python script using pyinstaller. If I compile as it is right now with</p>
  
  <pre><code>pyinstaller --onefile test5.py
  </code></pre>
  
  <p>The compile process will be fine, but I will still not be allowed to use the usb device when running the compiled file. Below is the full error report</p>
  
  <pre><code>(env) (base) hdadmin@HiddenDimsum:~/Documents/Python/POS$ cd /home/hdadmin/Documents/Python/POS ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /home/hdadmin/Documents/Python/POS/env/bin/python3.6 /home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 42379 /home/hdadmin/Documents/Python/POS/test4.py 
  Traceback (most recent call last):
    File "/home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/ptvsd_launcher.py", line 43, in &lt;module&gt;
      main(ptvsdArgs)
    File "/home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/__main__.py", line 432, in main
      run()
    File "/home/hdadmin/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/__main__.py", line 316, in run_file
      runpy.run_path(target, run_name='__main__')
    File "/usr/lib/python3.6/runpy.py", line 263, in run_path
      pkg_name=pkg_name, script_name=fname)
    File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
      mod_name, mod_spec, pkg_name, script_name)
    File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
      exec(code, run_globals)
    File "/home/hdadmin/Documents/Python/POS/test4.py", line 2, in &lt;module&gt;
      printer = Usb(1208, 3605)
    File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/escpos/printer.py", line 51, in __init__
      self.open()
    File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/escpos/printer.py", line 62, in open
      check_driver = self.device.is_kernel_driver_active(0)
    File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/core.py", line 1061, in is_kernel_driver_active
      self._ctx.managed_open()
    File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/core.py", line 102, in wrapper
      return f(self, *args, **kwargs)
    File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/core.py", line 120, in managed_open
      self.handle = self.backend.open_device(self.dev)
    File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 786, in open_device
      return _DeviceHandle(dev)
    File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 643, in __init__
      _check(_lib.libusb_open(self.devid, byref(self.handle)))
    File "/home/hdadmin/Documents/Python/POS/env/lib/python3.6/site-packages/usb/backend/libusb1.py", line 595, in _check
      raise USBError(_strerror(ret), ret, _libusb_errno[ret])
  usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
  </code></pre>
  
  <p>Since I am new to Linux and Ubuntu, I need help and advices so that I can get permission to the usb devices connected to my computer. The expected outcome is, I should be able to run the test5.py by without the need for </p>
  
  <p>sudo python3 -m test5.py</p>