-
Notifications
You must be signed in to change notification settings - Fork 15
AttributeError: 'str' object has no attribute 'encode' #9
Comments
I couldn't recreate this. Can you try running this interactively at the REPL as shown below and post results of that. Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0-alpha.5 on 2018-12-10; Adafruit Feather M4 Express with samd51j19
>>> import board
>>> import busio
>>> import adafruit_thermal_printer
>>> ThermalPrinter = adafruit_thermal_printer.get_printer_class(2.69)
>>> RX = board.RX
>>> TX = board.TX
>>> uart = busio.UART(TX, RX, baudrate=19200)
>>> printer = ThermalPrinter(uart, auto_warm_up=False)
>>> |
Ran in REPL
Just for extra info. Thermal Printer Connections |
@dhalbert @caternuson i wonder if this is a CPython compatibility thing? M4's have it. we can use some other function |
Hmmm. Yep. Just verifying it's not on M0. Left out for space saving? Will let @dhalbert answer as to why and what's a good substitute. Adafruit CircuitPython 4.0.0-alpha.5 on 2018-12-10; Adafruit Feather M0 Express with samd21g18
>>> 'encode' in dir("hello")
False Adafruit CircuitPython 4.0.0-alpha.5 on 2018-12-10; Adafruit Feather M4 Express with samd51j19
>>> 'encode' in dir("hello")
True
>>> This may be a related discussion. |
Is there any workaround for Fixed the issue by using Bytes(obj, 'ascii') in thermal_printer.py and converting it to .mpy |
Closing. Adafruit CircuitPython 4.1.0 on 2019-08-02; Adafruit Metro M0 Express with samd21g18
>>> 'encode' in dir("hello")
True
>>> "hello".encode('ascii')
b'hello'
>>> |
Oops. Except for non-Express M0's (Trinket, Gemma, etc.): Adafruit CircuitPython 4.1.0 on 2019-08-02; Adafruit Trinket M0 with samd21e18
>>> 'encode' in dir("hello")
False Adafruit CircuitPython 4.1.0 on 2019-08-02; Adafruit Gemma M0 with samd21e18
>>> 'encode' in dir("hello")
False Leaving closed since using a thermal printer with a non-Express board should be petty rare and generally not a recommended combo. |
@caternuson yep thats ok - please update the readme to let people know? |
okie dokie, here you go: #10 |
huzzah |
Circuit Python Version : Adafruit CircuitPython 4.0.0-alpha.5 on 2018-12-10; Adafruit Metro M0 Express with samd21g18
Thermal Printer Version : circuitpython-thermal-printer-4.x-mpy-1.1.2.zip
Im trying to run the example printer code & my code without luck
Example
and it returns this
The same error occurs with my code and the example code.
Im doing something wrong?
The text was updated successfully, but these errors were encountered: