Unable to satisfy from uasyncio.websocket.server import WSReader, WSWriter
-
Problem: I have a program that uses this:
import uasyncio
from uasyncio.websocket.server import WSReader, WSWriterI have tried:
upip.install('uasyncio')
upip.install('uasyncio.websocket')
upip.install('uasyncio.websocket.server')First Steps: (Proof of virginity)
python3 /home/gk/.local/bin/esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash
python3 /home/gk/.local/bin/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 ../esp32-20220618-v1.19.1.bin
Set up boot.py for network access and boothed the ESP32Starting from the top: upip.install('uasyncio')
import upip
upip.install('uasyncio')
Installing to: /lib/
Warning: micropython.org SSL certificate is not validated
Installing uasyncio 3.0 from https://micropython.org/pi/uasyncio/uasyncio-3.0.tar.gz
then:import main
Traceback (most recent call last):
...
ImportError: no module named 'uasyncio.websocket'Fair enough: do first steps again for a virgin board: upip.install('uasyncio.websocket')
import upip
upip.install('uasyncio.websocket')
Installing to: /lib/
Warning: micropython.org SSL certificate is not validated
Error installing 'uasyncio.websocket': Package not found, packages may be partially installedHere I am confused ... how can it be "partially installed" if the board was cleared and the bin re-written to it?
OK, so: do first steps again for a virgin board: no upip install this time:
import main
Traceback (most recent call last):
...
ImportError: no module named 'uasyncio.websocket'Not sure what is going on.
Help please!
Thisis from: https://forum.micropython.org/viewtopic.php?f=15&t=6568
<code>
import uasyncio
from uasyncio.websocket.server import WSReader, WSWriterdef echo(reader, writer):
# Consume GET line
yield from reader.readline()reader = yield from WSReader(reader, writer) writer = WSWriter(reader, writer) while 1: l = yield from reader.readline() print(l) if l == b"\r": await writer.awrite(b"\r\n") else: await writer.awrite(l)
import logging
logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.DEBUG)
loop = uasyncio.get_event_loop()
loop.create_task(uasyncio.start_server(echo, "192.168.4.1", 8081))
loop.run_forever()
loop.close()
</code>