#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2017
    Posts
    29
    Rep Power
    0

    Cool access denied error in python-printer-escpos


    i have attached a thermal printer to my raspberry...i used usb port and found idproduct and idvendor and inputendpoint and outputendpoint by lsusb -D....
    i used python-printer-escpos module
    my code is :
    Code:
    from escpos.connections import getUSBPrinter
    
    
    printer = getUSBPrinter()(idVendor=0x0483,
                              idProduct=0x5720,
                              inputEndPoint=0x81,
                              outputEndPoint=0x01) # Create the printer object with the connection params
    
    printer.text("Hello World")
    printer.lf()
    for setting up it...but i get the following error

    Code:
    [python]Traceback (most recent call last):
      File "/home/pi/start/printerr/poss/NEW/py-print-escposs.py", line 8, in <module>
        outputEndPoint=0x01) # Create the printer object with the connection params
      File "/usr/local/lib/python3.4/dist-packages/escpos/connections.py", line 87, in __init__
        self.__open()
      File "/usr/local/lib/python3.4/dist-packages/escpos/connections.py", line 106, in __open
        if self._device.is_kernel_driver_active(0):
      File "/usr/local/lib/python3.4/dist-packages/usb/core.py", line 1061, in is_kernel_driver_active
        self._ctx.managed_open()
      File "/usr/local/lib/python3.4/dist-packages/usb/core.py", line 102, in wrapper
        return f(self, *args, **kwargs)
      File "/usr/local/lib/python3.4/dist-packages/usb/core.py", line 120, in managed_open
        self.handle = self.backend.open_device(self.dev)
      File "/usr/local/lib/python3.4/dist-packages/usb/backend/libusb1.py", line 786, in open_device
        return _DeviceHandle(dev)
      File "/usr/local/lib/python3.4/dist-packages/usb/backend/libusb1.py", line 643, in __init__
        _check(_lib.libusb_open(self.devid, byref(self.handle)))
      File "/usr/local/lib/python3.4/dist-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)
    what is the problem?
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,838
    Rep Power
    509
    I sometimes have access to these printers and might be able to actually test the system. In the meantime, try running the program as root.

    $ sudo python3 program.py
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo