kabyru / govee-btled-controller

A re-implementation of govee_btled but with Windows compatibility.
GNU General Public License v3.0
0 stars 1 forks source link

pip install error #1

Open jonahclarsen opened 1 year ago

jonahclarsen commented 1 year ago

Hi there!

Thank you so much for making this, I really look forward to using it.

Unfortunately, I get this error when I run "pip install -U git+https://github.com/kabyru/govee_btled_windows" from my anaconda env (on Windows 10; formatting is messed up because some of it resembles markdown):

ERROR: Command errored out with exit status 1: command: 'C:\Users\jonah\Anaconda3\envs\govee\python.exe' 'C:\Users\jonah\Anaconda3\envs\govee\lib\site-packages\pip_vendor\pep517\in_process_in_process.py' build_wheel 'C:\Users\jonah\AppData\Local\Temp\tmp866a9q19' cwd: C:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51 Complete output (201 lines):

-- Trying "Ninja (Visual Studio 17 2022 x64 v143)" generator






-- Not searching for unused variables given on the command line. -- The C compiler identification is unknown CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE): The CMAKE_C_COMPILER:

  cl

is not a full path and was not found in the PATH.

Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred! See also "C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log". See also "C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/_cmake_test_compile/build/CMakeFiles/CMakeError.log".







-- Trying "Ninja (Visual Studio 17 2022 x64 v143)" generator - failure


-- Trying "Visual Studio 17 2022 x64 v143" generator






-- Not searching for unused variables given on the command line. CMake Error at CMakeLists.txt:2 (PROJECT): Generator

  Visual Studio 17 2022

could not find any instance of Visual Studio.

-- Configuring incomplete, errors occurred! See also "C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".







-- Trying "Visual Studio 17 2022 x64 v143" generator - failure


-- Trying "Ninja (Visual Studio 16 2019 x64 v142)" generator






-- Not searching for unused variables given on the command line. -- The C compiler identification is MSVC 19.29.30146.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx86/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- The CXX compiler identification is MSVC 19.29.30146.0 CMake Warning (dev) at C:/Users/jonah/AppData/Local/Temp/pip-build-env-ja7y0u6m/overlay/Lib/site-packages/cmake/data/share/cmake-3.25/Modules/CMakeDetermineCXXCompiler.cmake:162 (if): Policy CMP0054 is not set: Only interpret if() arguments as variables or keywords when unquoted. Run "cmake --help-policy CMP0054" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

Quoted variables like "MSVC" will no longer be dereferenced when the policy
is set to NEW.  Since the policy is not set the OLD behavior will be used.

Call Stack (most recent call first): CMakeLists.txt:4 (ENABLE_LANGUAGE) This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at C:/Users/jonah/AppData/Local/Temp/pip-build-env-ja7y0u6m/overlay/Lib/site-packages/cmake/data/share/cmake-3.25/Modules/CMakeDetermineCXXCompiler.cmake:183 (elseif): Policy CMP0054 is not set: Only interpret if() arguments as variables or keywords when unquoted. Run "cmake --help-policy CMP0054" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

Quoted variables like "MSVC" will no longer be dereferenced when the policy
is set to NEW.  Since the policy is not set the OLD behavior will be used.

Call Stack (most recent call first): CMakeLists.txt:4 (ENABLE_LANGUAGE) This warning is for project developers. Use -Wno-dev to suppress it.

-- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx86/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/_cmake_test_compile/build







-- Trying "Ninja (Visual Studio 16 2019 x64 v142)" generator - success

Configuring Project Working directory: C:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51_skbuild\win-amd64-3.6\cmake-build Command: cmake 'C:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51' -G Ninja '-DCMAKE_INSTALL_PREFIX:PATH=C:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51_skbuild\win-amd64-3.6\cmake-install' -DPYTHON_VERSION_STRING:STRING=3.6.4 -DSKBUILD:INTERNAL=TRUE '-DCMAKE_MODULE_PATH:PATH=C:\Users\jonah\AppData\Local\Temp\pip-build-env-ja7y0u6m\overlay\Lib\site-packages\skbuild\resources\cmake' '-DPYTHON_EXECUTABLE:PATH=C:\Users\jonah\Anaconda3\envs\govee\python.exe' '-DPYTHON_INCLUDE_DIR:PATH=C:\Users\jonah\Anaconda3\envs\govee\Include' '-DPYTHON_LIBRARY:PATH=C:\Users\jonah\Anaconda3\envs\govee\libs\python36.lib' '-DPython_EXECUTABLE:PATH=C:\Users\jonah\Anaconda3\envs\govee\python.exe' '-DPython_ROOT_DIR:PATH=C:\Users\jonah\Anaconda3\envs\govee' '-DPython_INCLUDE_DIR:PATH=C:\Users\jonah\Anaconda3\envs\govee\Include' -DPython_FIND_REGISTRY:STRING=NEVER '-DPython3_EXECUTABLE:PATH=C:\Users\jonah\Anaconda3\envs\govee\python.exe' '-DPython3_ROOT_DIR:PATH=C:\Users\jonah\Anaconda3\envs\govee' '-DPython3_INCLUDE_DIR:PATH=C:\Users\jonah\Anaconda3\envs\govee\Include' -DPython3_FIND_REGISTRY:STRING=NEVER '-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\Users\jonah\AppData\Local\Temp\pip-build-env-ja7y0u6m\overlay\Lib\site-packages\ninja\data\bin\ninja' -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE:STRING=Release

-- The C compiler identification is MSVC 19.29.30146.0 -- The CXX compiler identification is MSVC 19.29.30146.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx86/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx86/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/_winrt.cpp C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/py.Windows.Devices.Bluetooth.Advertisement.cpp C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/py.Windows.Devices.Bluetooth.Background.cpp C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/py.Windows.Devices.Bluetooth.GenericAttributeProfile.cpp C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/py.Windows.Devices.Bluetooth.cpp C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/py.Windows.Devices.Enumeration.cpp C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/py.Windows.Foundation.Collections.cpp C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/py.Windows.Foundation.cpp C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/py.Windows.Storage.Streams.cpp C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/pywinrt/bleak_winrt/src/runtime.cpp -- Found Python3: C:/Users/jonah/Anaconda3/envs/govee/python.exe (found suitable exact version "3.6.4") found components: Interpreter Development Development.Module Development.Embed -- Configuring done -- Generating done CMake Warning: Manually-specified variables were not used by the project:

  PYTHON_EXECUTABLE
  PYTHON_INCLUDE_DIR
  PYTHON_LIBRARY
  Python_EXECUTABLE
  Python_FIND_REGISTRY
  Python_INCLUDE_DIR
  Python_ROOT_DIR
  SKBUILD

-- Build files have been written to: C:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/_skbuild/win-amd64-3.6/cmake-build [1/13] Building CXX object CMakeFiles_winrt.dir\cmake_pch.cxx.obj FAILED: CMakeFiles/_winrt.dir/cmake_pch.cxx.obj C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x64\cl.exe /nologo /TP -D_winrt_EXPORTS -IC:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51\cppwinrt -IC:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51\pywinrt\bleak_winrt\src -external:IC:\Users\jonah\Anaconda3\envs\govee\Include -external:W0 /DWIN32 /D_WINDOWS /EHsc /d2FH4 /O2 /Ob2 /DNDEBUG -MT /await /bigobj /GR- /permissive- -std:c++17 /YcC:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/_skbuild/win-amd64-3.6/cmake-build/CMakeFiles/_winrt.dir/cmake_pch.hxx /FpC:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/_skbuild/win-amd64-3.6/cmake-build/CMakeFiles/_winrt.dir/./cmake_pch.cxx.pch /FIC:/Users/jonah/AppData/Local/Temp/pip-install-23kk9uq9/bleak-winrt_aabdcddada664176a5fa73ac5647dc51/_skbuild/win-amd64-3.6/cmake-build/CMakeFiles/_winrt.dir/cmake_pch.hxx /showIncludes /FoCMakeFiles_winrt.dir\cmake_pch.cxx.obj /FdCMakeFiles_winrt.dir\ /FS -c C:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51_skbuild\win-amd64-3.6\cmake-build\CMakeFiles_winrt.dir\cmake_pch.cxx C:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51\pywinrt\bleak_winrt\src\pybase.h(939): error C2065: 'PyDateTime_TimeZone_UTC': undeclared identifier C:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51\pywinrt\bleak_winrt\src\pybase.h(972): error C2065: 'PyDateTime_TimeZone_UTC': undeclared identifier ninja: build stopped: subcommand failed. Traceback (most recent call last): File "C:\Users\jonah\AppData\Local\Temp\pip-build-env-ja7y0u6m\overlay\Lib\site-packages\skbuild\setuptools_wrap.py", line 640, in setup cmkr.make(make_args, install_target=cmake_install_target, env=env) File "C:\Users\jonah\AppData\Local\Temp\pip-build-env-ja7y0u6m\overlay\Lib\site-packages\skbuild\cmaker.py", line 684, in make self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env) File "C:\Users\jonah\AppData\Local\Temp\pip-build-env-ja7y0u6m\overlay\Lib\site-packages\skbuild\cmaker.py", line 716, in make_impl "An error occurred while building with CMake.\n"

An error occurred while building with CMake. Command: cmake --build . --target install --config Release -- Install target: install Source directory: C:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51 Working directory: C:\Users\jonah\AppData\Local\Temp\pip-install-23kk9uq9\bleak-winrt_aabdcddada664176a5fa73ac5647dc51_skbuild\win-amd64-3.6\cmake-build Please check the install target is valid and see CMake's output for more information.

ERROR: Failed building wheel for bleak-winrt Successfully built govee-btled-windows Failed to build bleak-winrt ERROR: Could not build wheels for bleak-winrt which use PEP 517 and cannot be installed directly

jonahclarsen commented 1 year ago

I was able to install it without a hitch on my M2 Macbook Air. To run the test program, however, I had to change from govee_btled import BluetoothLED to from govee_btled_windows import BluetoothLED and comment out from shades_of_white import values as SHADES_OF_WHITE in bluetooth_led.py to silence a "shades_of_white not found" error.

However, when I ran the test program, the light is not affected and I get the following error (I'm sure the MAC address is correct):

Traceback (most recent call last): File "/Users/me/Documents/Album Art BG/_Python program/main.py", line 35, in led = BluetoothLED('A4:C1:38:96:14:A8') File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/site-packages/govee_btled_windows/bluetooth_led.py", line 43, in init asyncio.run(connectClient()) File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/site-packages/govee_btled_windows/bluetooth_led.py", line 41, in connectClient await self._bt.connect() File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/site-packages/bleak/init.py", line 471, in connect return await self._backend.connect(**kwargs) File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/site-packages/bleak/backends/corebluetooth/client.py", line 84, in connect raise BleakDeviceNotFoundError( bleak.exc.BleakDeviceNotFoundError: Device with address A4:C1:38:96:14:A8 was not found

kabyru commented 1 year ago

I was able to install it without a hitch on my M2 Macbook Air. To run the test program, however, I had to change from govee_btled import BluetoothLED to from govee_btled_windows import BluetoothLED and comment out from shades_of_white import values as SHADES_OF_WHITE in bluetooth_led.py to silence a "shades_of_white not found" error.

However, when I ran the test program, the light is not affected and I get the following error (I'm sure the MAC address is correct):

Traceback (most recent call last): File "/Users/me/Documents/Album Art BG/_Python program/main.py", line 35, in led = BluetoothLED('A4:C1:38:96:14:A8') File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/site-packages/govee_btled_windows/bluetooth_led.py", line 43, in init asyncio.run(connectClient()) File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/site-packages/govee_btled_windows/bluetooth_led.py", line 41, in connectClient await self._bt.connect() File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/site-packages/bleak/init.py", line 471, in connect return await self._backend.connect(**kwargs) File "/Users/me/opt/miniconda3/envs/govee/lib/python3.10/site-packages/bleak/backends/corebluetooth/client.py", line 84, in connect raise BleakDeviceNotFoundError( bleak.exc.BleakDeviceNotFoundError: Device with address A4:C1:38:96:14:A8 was not found

Hey, just wanted you to know I just saw this issue. My initial theory is that your pip errors are something to do with Bleak. But let me give it a look and I'll get back with you.

kabyru commented 1 year ago

Hey,

Regarding your first build issue. That looks like to me that Bleak is having trouble installing on your machine for some reason. Perhaps there is some missing library you need to install Bleak. I found a similar issue regarding a different package here: https://stackoverflow.com/questions/64038673/could-not-build-wheels-for-which-use-pep-517-and-cannot-be-installed-directly

Looks like the Error you got is a boiler plate error relating to PEP 517 and could be related to your PIP and Setuptools versions. Might not hurt to install Bleak by itself on your machine first to see if you get different results.

Relating to your second issue, I repeated this problem on my machine by providing a dummy MAC address:

Traceback (most recent call last):
  File ".\testbench.py", line 3, in <module>
    led = BluetoothLED('XX:XX:XX:XX:XX:XX')
  File "C:\Users\kaleb\anaconda3\lib\site-packages\govee_btled_windows\bluetooth_led.py", line 43, in __init__
    asyncio.run(connectClient())
  File "C:\Users\kaleb\anaconda3\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\Users\kaleb\anaconda3\lib\asyncio\base_events.py", line 583, in run_until_complete
    return future.result()
  File "C:\Users\kaleb\anaconda3\lib\site-packages\govee_btled_windows\bluetooth_led.py", line 41, in connectClient
    await self._bt.connect()
  File "C:\Users\kaleb\anaconda3\lib\site-packages\bleak\__init__.py", line 471, in connect
    return await self._backend.connect(**kwargs)
  File "C:\Users\kaleb\anaconda3\lib\site-packages\bleak\backends\winrt\client.py", line 245, in connect
    self.address, f"Device with address {self.address} was not found."
bleak.exc.BleakDeviceNotFoundError: Device with address XX:XX:XX:XX:XX:XX was not found.

It looks like to me that Bleak is having trouble finding this device you're trying to connect to. I would first recommend ensuring the MAC of the device you want is the right one, and then in turn ensure that Windows/Mac can find it using its Bluetooth Discovery tools. I wrote a troubleshooting tool for this case called search_btle.py that's in this repo that might be of use.

jonahclarsen commented 1 year ago

Hi!

You were right, the MAC wasn't right - for some reason the MAC scanner app I used on my phone gave me a MAC address in the format 'A4:C1:38:96:14:A8', but running search_btle.py on my Mac gave me a MAC address in the format '5A776407-2501-4541-248E-E635DD6CE3F3'.

When I put the new MAC address into the test program, it works! Although I now get name 'SHADES_OF_WHITE' is not defined, presumably because I had to comment out "from shades_of_white import values as SHADES_OF_WHITE" - how do I install 'shades_of_white'? pip install shades_of_white doesn't work.

I will work more on trying to get it working on Windows later.

Thanks for your help so far! This is awesome.

jonahclarsen commented 1 year ago

I figured out the shades of white thing - I just had to include this file from the original govee_btled repo in my working directory: https://github.com/chvolkmann/govee_btled/blob/master/govee_btled/shades_of_white.py. It would probably help people going forward if you included that in this repo.

jonahclarsen commented 1 year ago

I had a problem where the set_color() function was incredibly hit or miss - it seems to only work a small fraction of the times I run it, and sometimes maybe even sends a different color than what I specified, seemingly at random. I discovered that, unlike the other two functions, set_color() requires you to first run led.set_state(True), which I had disabled when I realized it wasn't necessary for the other two functions. It may be helpful to include a brief comment regarding this for future users.

kabyru commented 1 year ago

I figured out the shades of white thing - I just had to include this file from the original govee_btled repo in my working directory: https://github.com/chvolkmann/govee_btled/blob/master/govee_btled/shades_of_white.py. It would probably help people going forward if you included that in this repo.

For sure. I goofed and didn't include it in the first place.... Thanks a lot for the catch.

kabyru commented 1 year ago

I had a problem where the set_color() function was incredibly hit or miss - it seems to only work a small fraction of the times I run it, and sometimes maybe even sends a different color than what I specified, seemingly at random. I discovered that, unlike the other two functions, set_color() requires you to first run led.set_state(True), which I had disabled when I realized it wasn't necessary for the other two functions. It may be helpful to include a brief comment regarding this for future users.

Also an excellent find. Thanks again for all the discoveries. I'll push an update to the readme and include the shades of white file once I get a hold of my computer.

Have a happy holiday!