Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run fails with cannot import name 'IOBluetoothDeviceInquiry' #18

Open
artemptushkin opened this issue Jan 23, 2022 · 6 comments
Open

Run fails with cannot import name 'IOBluetoothDeviceInquiry' #18

artemptushkin opened this issue Jan 23, 2022 · 6 comments

Comments

@artemptushkin
Copy link

Hey! Could you assist please with installation, I keep getting these. Tried to reinstall everything I knew.

I'm from Java and quite newbie with python env

ego-hub-tk git:(main) ✗ python3 run_command.py
Traceback (most recent call last):
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/run_command.py", line 17, in <module>
    from comm.HubClient import ConnectionState, HubClient
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/comm/HubClient.py", line 5, in <module>
    from comm.MultiplexedConnectionMonitor import MultiplexedConnectionMonitor
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/comm/MultiplexedConnectionMonitor.py", line 2, in <module>
    from comm.BluetoothConnectionMonitor import BluetoothConnectionMonitor
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/comm/BluetoothConnectionMonitor.py", line 4, in <module>
    import bluetooth
  File "/usr/local/lib/python3.9/site-packages/bluetooth/__init__.py", line 13, in <module>
    from bluetooth.macos import *
  File "/usr/local/lib/python3.9/site-packages/bluetooth/macos/__init__.py", line 1, in <module>
    import bluetooth.macos.discovery as discovery
  File "/usr/local/lib/python3.9/site-packages/bluetooth/macos/discovery.py", line 6, in <module>
    from Foundation import NSObject, IOBluetoothDeviceInquiry
ImportError: cannot import name 'IOBluetoothDeviceInquiry' from 'Foundation._context' (/usr/local/lib/python3.9/site-packages/Foundation/_context.py)
➜  lego-hub-tk git:(main) ✗
@Nurech
Copy link

Nurech commented Jan 23, 2022

Hey! Could you assist please with installation, I keep getting these. Tried to reinstall everything I knew.

I'm from Java and quite newbie with python env

ego-hub-tk git:(main) ✗ python3 run_command.py
Traceback (most recent call last):
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/run_command.py", line 17, in <module>
    from comm.HubClient import ConnectionState, HubClient
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/comm/HubClient.py", line 5, in <module>
    from comm.MultiplexedConnectionMonitor import MultiplexedConnectionMonitor
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/comm/MultiplexedConnectionMonitor.py", line 2, in <module>
    from comm.BluetoothConnectionMonitor import BluetoothConnectionMonitor
  File "/Users/artemptushkin/PycharmProjects/lego-hub-tk/comm/BluetoothConnectionMonitor.py", line 4, in <module>
    import bluetooth
  File "/usr/local/lib/python3.9/site-packages/bluetooth/__init__.py", line 13, in <module>
    from bluetooth.macos import *
  File "/usr/local/lib/python3.9/site-packages/bluetooth/macos/__init__.py", line 1, in <module>
    import bluetooth.macos.discovery as discovery
  File "/usr/local/lib/python3.9/site-packages/bluetooth/macos/discovery.py", line 6, in <module>
    from Foundation import NSObject, IOBluetoothDeviceInquiry
ImportError: cannot import name 'IOBluetoothDeviceInquiry' from 'Foundation._context' (/usr/local/lib/python3.9/site-packages/Foundation/_context.py)
➜  lego-hub-tk git:(main) ✗

Lego-hub-tk (as per docs) should be located somewhere like this: C:\Users\artemptushki\AppData\Local\lego-hub-tk
Did you run command pip3 install -r requirements.txt inside lego-hub-tk?

@artemptushkin
Copy link
Author

@Nurech yes I did, well for me (macbook) it's located not in AppData. I'm wondering, maybe MacBook env affects this as when I go through the trace I see there if on OS, so it might be on Windows. But I think this is a question of the library then pip3 install pybluez I installed this, but still have issue

@smr99
Copy link
Owner

smr99 commented Jan 23, 2022

Hello and thanks for reporting this. I don't use mac, but @ws1088 has tested on mac -- maybe could offer some insight?

Disclaimer aside, since the error occurs on "import bluetooth" it looks like there's something amiss with the bluetooth python packages. I don't have any advice other than consult mac users of python bluetooth. Sorry.

@SpudGunMan
Copy link
Contributor

SpudGunMan commented Jan 29, 2022

pybluez dependency is likely the issue I haven't tried on osx but also causes issues for raspberry as well I think

macosx issues on pybluez github

@SpudGunMan
Copy link
Contributor

SpudGunMan commented Jan 31, 2022

Mac issue is changes in the way that UUID and SerialUSB was working osx12.3 aims to fix them however the packages will need to be updated to facilitate this, pybluez project might be slower on the shift. https://github.com/Jakeler/ble-serial is an attractive project inline with this issue worth looking at

@smr99
Copy link
Owner

smr99 commented Feb 1, 2022

Mac issue is changes in the way that UUID and SerialUSB was working osx12.3 aims to fix them however the packages will need to be updated to facilitate this, pybluez project might be slower on the shift. https://github.com/Jakeler/ble-serial is an attractive project inline with this issue worth looking at

I actually have code removing the need for pybluez in the core bluetooth communications code. I will get that committed soon. The only thing I couldn't work out how to do is detect the device -- which is only of value if you want the "usb/bt multiplexing".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants