An application is being developed to control a thermal printer. The script to control the thermal printer is being executed from a Docker container.
This printer is attached to a USB port of a Raspberry Pi 4. The programming language is Python. There is an error at the time of configuration of the printer, that needs to be resolved. The following are scripts of Dockerfile, Requirements and the Error:
Dockerfile:
FROM python:3.8.3-alpine
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install psycopg2 dependencies
RUN apk update \
&& apk add postgresql-dev gcc python3-dev musl-dev
RUN apk add libjpeg-turbo-dev freetype-dev libpng-dev libusb
RUN apk add --update --no-cache curl jq py3-configobj py3-pip py3-setuptools python3 python3-dev
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
# copy entrypoint.sh
COPY ./entrypoint.sh .
# copy project
COPY . .
# run entrypoint.sh
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
Requirements:
Django==3.0.7
python-escpos==2.2.0
gunicorn==20.0.4
requests==2.24.0
psycopg2==2.8.5
psycopg2-binary==2.8.5
djangorestframework==3.11.0
django-cors-headers==3.4.0
pyusb==1.1.0
libusb1==1.9.1
libusb==1.0.23b7
pytz
escpos==1.8
Error:
Warning: missing lib... win32print
print paper
Traceback (most recent call last):
File "services/receipt_content.py", line 123, in <module>
a = ReceiptHeader("165465481654654", "app/media/loto.png", None)
File "services/receipt_content.py", line 29, in _init_
PrintPaper._init_(self)
File "services/receipt_content.py", line 10, in _init_
self.printer = Usb(0x0fef, 0x811e, 98, 0x82, 0x02)
File "/usr/local/lib/python3.8/site-packages/escpos/printer.py", line 50, in _init_
usb_args['idVendor'] = idVendor
TypeError: 'int' object does not support item assignment