virantha / bricknil

Control LEGO Bluetooth Sensors and Motors with Python
https://virantha.github.io/bricknil
Apache License 2.0
142 stars 39 forks source link

Windows 11: Bleak discover has an exception: Unhandled Exception: System.NotSupportedException: Cannot create uninitialized instances of types requiring managed activation. #32

Open AshleyPinner opened 1 year ago

AshleyPinner commented 1 year ago

Hello!

After installing python on Windows 11 and then bricknil, and then patching stuff so it'd actually run (and not error about imports)< I can't seem to get any of the example code working:

> python train-control.py
started thread for curio
DEBUG:asyncio:Using proactor: IocpProactor
inside curio run loop
INFO:BLE Event Q.0:using bleak
DEBUG:train1.2:Decorating class Train with TrainMotor
INFO:BLE Event Q.0:Starting scan for UART 00001623-1212-efde-1623-785feabcd123
INFO:BLE Event Q.0:Looking for first matching hub
Awaiting on bleak discover

Unhandled Exception: System.NotSupportedException: Cannot create uninitialized instances of types requiring managed activation.
   at System.Runtime.Serialization.FormatterServices.nativeGetUninitializedObject(RuntimeType type)
   at Python.Runtime.ClassObject.tp_new_impl(BorrowedReference tp, BorrowedReference args, BorrowedReference kw)
   at Python.Runtime.NativeCall.Call_3(IntPtr fp, BorrowedReference a1, BorrowedReference a2, BorrowedReference a3)
   at Python.Runtime.MetaType.tp_call(BorrowedReference tp, BorrowedReference args, BorrowedReference kw)

I get this error even if I try running the python code in an elevated cmd instance.

I'm not sure how to progress; it seems like some .net error, but none of the google hits indicate what the issue is or how to resolve it.

Any thoughts?