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

ModuleNotFoundError: No module named 'Windows' #13

Open ElTentakel opened 4 years ago

ElTentakel commented 4 years ago

I just did a clean installation of Python 32bit and Bricknil under Windows 10 1903:

pip install bricknil ... 'Successfully installed bluebrick-Adafruit-BluefruitLE-0.9.13 bricknil-0.9.3 bricknil-bleak-0.3.1 curio-1.2 future-0.18.2 pythonnet-2.4.0 pyyaml-5.3.1'

and tried this sample:

from curio import sleep
from bricknil import attach, start
from bricknil.hub import PoweredUpHub
from bricknil.sensor import TrainMotor

@attach(TrainMotor, name='motor')
class Train(PoweredUpHub):

    async def run(self):
        for i in range(2):  # Repeat this control two times
            await self.motor.ramp_speed(80,5000) # Ramp speed to 80 over 5 seconds
            await sleep(6)
            await self.motor.ramp_speed(0,1000)  # Brake to 0 over 1 second
            await sleep(2)

async def system():
    hub = Train("My train", ble_id="90:84:2B:03:xx:xx")

if __name__ == '__main__':
    start(system)

and it didn't work:

Type "help", "copyright", "credits" or "license()" for more information.
>>> 
============= RESTART: C:\Users\User\Desktop\Bricknil\bricktest.py ============
Traceback (most recent call last):
  File "C:\Users\User\Desktop\Bricknil\bricktest.py", line 20, in <module>
    start(system)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\bricknil\bricknil.py", line 207, in start
    from .bleak_interface import Bleak
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\bricknil\bleak_interface.py", line 20, in <module>
    import bleak
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\bleak\__init__.py", line 68, in <module>
    from bleak.backends.dotnet.discovery import discover  # noqa
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\bleak\backends\dotnet\discovery.py", line 17, in <module>
    from Windows.Devices.Bluetooth.Advertisement import BluetoothLEAdvertisementWatcher
ModuleNotFoundError: No module named 'Windows'
>>> 
joosbuijsNL commented 4 years ago

+1

I am also trying to run bricknil on Windows 10 but get this error message. Looking forward to a solution or hint!

BuongiornoTexas commented 4 years ago

I was able to do a quick fix for based on https://github.com/hbldh/bleak/issues/53#issuecomment-473875499. (I'm assuming https://github.com/virantha/bricknil/issues/19 is a better long term fix though)

Sebwap commented 2 years ago

Work for me too, :) But why using a so old version of Bleak ?