hrvach/espple

Compile Error - TypeError: a bytes-like object is required, not 'str'

ds2k5 opened this issue · 3 comments

ds2k5 commented

Hello,
I tryed to build the wifi_credentials.bin but did not work, got only 0 byte file

$ make credentials ssid="MyWLAN" password="MyPassword"
python -c "open('wifi_credentials.bin', 'wb').write(''.join(i.ljust(32, '\0') for i in ['MyWLAN','MyPassword']))"
Traceback (most recent call last):
File "", line 1, in
TypeError: a bytes-like object is required, not 'str'
make: *** [Makefile:44: credentials] Fehler 1

Python 2.7.14
Python 3.6.4

How to fix this ?
Thanks

Try running it manually with python2 -c "open... or edit Makefile and change python to python2.

Does it work then?

ds2k5 commented

python2 -c "open('wifi_credentials.bin', 'wb').write(''.join(i.ljust(32, '\0') for i in ['MyWLAN','MyPassword']))"
/usr/share/esptool/esptool.py --port /dev/ttyUSB0 write_flash 0x3c000 wifi_credentials.bin
make: /usr/share/esptool/esptool.py: Kommando nicht gefunden
make: *** [Makefile:45: credentials] Fehler 127

did not have the esptool.py
but /usr/bin/esptool

changed the following in Makefile:

credentials :
python -c

to:

credentials :
python2 -c

ESPTOOL_PY:=/usr/share/esptool/esptool.py
to
ESPTOOL_PY:=/usr/bin/esptool

so it works for me!

thank you very much

@ds2k5 You're very welcome. It's assuming that python2 is still a default for everyone. I will try to re-write the routine so it runs on both 2 and 3, sorry it didn't work for you out of the box.

Have fun!