Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
WSListener
✓ from picows import WSListener
Main listener class for creating WebSocket handlers.
WSFrame
✓ from picows import WSFrame
Frame type used in callbacks.
WSMsgType
✓ from picows import WSMsgType
Enum for message types (TEXT, BINARY, CLOSE, etc.).
ws_connect
✓ from picows import ws_connect
Client connection function.
WsServer
✓ from picows import WsServer
✗ picows.ws_server
Server class exported directly, not a module.
serve_ws
✓ from picows import serve_ws
Convenience function to create and run a server.
Connect to a WebSocket echo server, send a message, and print any received text frames.
import asyncio
from picows import WSListener, WSFrame, ws_connect, WSMsgType
class MyListener(WSListener):
def on_ws_connected(self, transport):
print("Connected")
def on_ws_frame(self, transport: WSFrame):
if transport.msg_type == WSMsgType.TEXT:
print(f"Received: {transport.get_text()}")
elif transport.msg_type == WSMsgType.CLOSE:
print("Server closed connection")
async def main():
transport = await ws_connect("ws://echo.websocket.org", MyListener)
await transport.send_text("Hello")
await asyncio.sleep(2)
asyncio.run(main())
Errors
Common errors & fixes
AttributeError: module 'picows' has no attribute 'ws_server'
Using deprecated or removed function 'ws_server'. It was renamed to 'serve_ws' in version 2.1.0.
fixUse 'from picows import serve_ws' and call serve_ws(...).
TypeError: object NoneType can't be used in 'await' expression
Attempting to await a method that returns None, e.g., forgetting to return a coroutine from a WSListener method.
fixEnsure that WSListener methods that should be awaitable (like on_ws_connected) are defined with async def.
ImportError: cannot import name 'ws_connect' from 'picows'
Incorrect import path or outdated version. ws_connect is exported from picows since version 2.0.
fixUpgrade to picows >=2.0.0 with 'pip install --upgrade picows' and use 'from picows import ws_connect'.
Upgrade
Version history
2.1.1latest on PyPI · released Jun 5, 2026
Audit
Dependencies
cythonoptionalCompilation dependency for building from source, but wheels are provided.