Page 1 of 1

error : USBPrinter instance has no attribute '_Generic__write'

Posted: Sun Jul 30, 2017 3:56 am
by gray_farz
hello friends...
i want to setup a thermal printer by python-printer-escpos module...
my code is :

Code: Select all

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()
i get this error :

Code: Select all

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/python2.7/dist-packages/escpos/connections.py", line 89, in __init__
    self.initialize()
  File "/usr/local/lib/python2.7/dist-packages/escpos/commandset/generic.py", line 463, in initialize
    self.__write(self.__class__.__ESC + '@')
AttributeError: USBPrinter instance has no attribute '_Generic__write'
what is problem?????
please help
i need it instantly

Re: error : USBPrinter instance has no attribute '_Generic__write'

Posted: Sun Jul 30, 2017 11:25 am
by ait
Hello,
(idVendor=0x0483,
idProduct=0x5720,
0483:5720 seemed to be a USB flashdrive
Bus 003 Device 009: ID 0483:5720 STMicroelectronics STM microSD Flash Device

Re: error : USBPrinter instance has no attribute '_Generic__write'

Posted: Sun Jul 30, 2017 2:21 pm
by scruss
Some of these USB printers have no descriptive text in the lsusb output, so it's easy to use the wrong device.

(which is another way of saying I've done this too …)