Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Issues while running the image print python code on raspberry pi3 (latest stretch raspian lite version) #29

Open
titusece opened this issue May 25, 2018 · 5 comments

Comments

@titusece
Copy link

Hello Experts,

pip3 install pyserial
pip3 install image
python3 sudoku-gfx.py

pi@camera1-rpi3:~/Python-Thermal-Printer $ python3 sudoku-gfx.py 
Traceback (most recent call last):
  File "sudoku-gfx.py", line 29, in <module>
    printer = Adafruit_Thermal("/dev/serial0", 9600, timeout=5)
  File "/home/pi/Python-Thermal-Printer/Adafruit_Thermal.py", line 96, in __init__
    self.wake()
  File "/home/pi/Python-Thermal-Printer/Adafruit_Thermal.py", line 606, in wake
    self.writeBytes(255)
  File "/home/pi/Python-Thermal-Printer/Adafruit_Thermal.py", line 190, in writeBytes
    super(Adafruit_Thermal, self).write(chr(arg))
  File "/home/pi/.local/lib/python3.5/site-packages/serial/serialposix.py", line 532, in write
    d = to_bytes(data)
  File "/home/pi/.local/lib/python3.5/site-packages/serial/serialutil.py", line 63, in to_bytes
    raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
TypeError: unicode strings are not supported, please encode to bytes: 'ÿ'
pi@camera1-rpi3:~/Python-Thermal-Printer $ 

Getting the above error logs while running the sudoku image based printer example.
Can you please help me to solve the issue ?
Thanks for the help.

@sharkwheels
Copy link

sharkwheels commented Jun 24, 2018

I am also getting this issue, only out of python 3.5 though. Has anyone come back to this since it was posted?

@alexholsgrove
Copy link

The code is pretty old now so I imagine it needs to be converted to run under Python3 instead of Python2

@ConorMatthews
Copy link

ConorMatthews commented Aug 16, 2018

Use this library https://github.com/gasperphoenix/Python-Thermal-Printer/tree/Python3andRaspberryPi3

It was forked from the adafruit library. Some examples still need to be ported to python 3, but it is easy to make your own programs. You NEED to change Adafruit_Thermal('/dev/serial0', 19200, timeout=5) to Adafruit_Thermal('/dev/ttyS0', 19200, timeout=5).

Hope this helps 👍

@gmpmovies
Copy link

Use this library https://github.com/gasperphoenix/Python-Thermal-Printer/tree/Python3andRaspberryPi3

I tried this, however I'm getting the exact same error as well when running Python 3.7.3 (It works fine with Python 2 though)

@ladyada
Copy link
Member

ladyada commented Aug 1, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants