実現したいこと
ラズパイ4でサーマルプリンターを使いたいです。Symcode 58MM
参考サイト
https://raspida.com/thermalprinter4rpi
https://python-escpos.readthedocs.io/en/latest/index.html
コードは下記です。
Python
1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4from escpos.printer import Usb 5#from escpos import * 6 7p = Usb(0x0416, 0x5011, 0, 0x86, 0x07) 8p.text("Hello World\n") 9p.cut()
発生している問題・分からないこと
エラーがでました。
エラーメッセージ
error
1pi@raspberrypi:~/Documents $ sudo python receipt001.py 2Traceback (most recent call last): 3 File "/home/pi/Documents/receipt001.py", line 4, in <module> 4 p.text("Hello World\n") 5 File "/usr/local/lib/python3.9/dist-packages/escpos/escpos.py", line 863, in text 6 self.magic.write(str(txt)) 7 File "/usr/local/lib/python3.9/dist-packages/escpos/magicencode.py", line 282, in write 8 self.write_with_encoding(encoding, to_write) 9 File "/usr/local/lib/python3.9/dist-packages/escpos/magicencode.py", line 304, in write_with_encoding 10 self.driver._raw( 11 File "/usr/local/lib/python3.9/dist-packages/escpos/printer/usb.py", line 189, in _raw 12 assert self.device 13 File "/usr/local/lib/python3.9/dist-packages/escpos/escpos.py", line 146, in device 14 self.open() 15 File "/usr/local/lib/python3.9/dist-packages/escpos/printer/usb.py", line 44, in wrapper 16 raise RuntimeError( 17RuntimeError: Printing with USB connection requires a usb library tobe installed. Please refer to the documentation onwhat to install and install the dependencies for USB. 18Exception ignored in: <function Escpos.__del__ at 0xf6b84850> 19Traceback (most recent call last): 20 File "/usr/local/lib/python3.9/dist-packages/escpos/escpos.py", line 134, in __del__ 21 File "/usr/local/lib/python3.9/dist-packages/escpos/printer/usb.py", line 44, in wrapper 22RuntimeError: Printing with USB connection requires a usb library tobe installed. Please refer to the documentation onwhat to install and install the dependencies for USB.
該当のソースコード
Python
1特になし
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
pyusbなどはインストールされています。
ただ、もとのドキュメントを見ると、
pythonのバージョンがいけないのかもと思いました。
補足
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー