Betree / magicblue

💡 Unofficial Python API to control Magic Blue bulbs over Bluetooth
MIT License
100 stars 23 forks source link

[Errno 2] No such file or directory: '/usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper' #11

Closed IzzyWizzy666 closed 7 years ago

IzzyWizzy666 commented 7 years ago

Hi Betree,

I'm having some problems connecting to my bulbs (V8) with the software (the GATT tool works fine) this is my error....

sudo magicblueshell -c 'set_color red' -m F2:F1:09:E6:DE:78 Traceback (most recent call last): File "/usr/local/bin/magicblueshell", line 11, in load_entry_point('magicblue==0.2.2', 'console_scripts', 'magicblueshell')() File "/usr/local/lib/python3.4/dist-packages/magicblue/magicblueshell.py", line 246, in main shell.cmd_connect([params.mac_address]) File "/usr/local/lib/python3.4/dist-packages/magicblue/magicblueshell.py", line 133, in cmd_connect self._magic_blue.connect(self.bluetooth_adapter) File "/usr/local/lib/python3.4/dist-packages/magicblue/magicbluelib.py", line 49, in connect bluetooth_adapter_nr) File "/usr/local/lib/python3.4/dist-packages/bluepy/btle.py", line 318, in init self.connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.4/dist-packages/bluepy/btle.py", line 353, in connect self._startHelper() File "/usr/local/lib/python3.4/dist-packages/bluepy/btle.py", line 210, in _startHelper universal_newlines=True) File "/usr/lib/python3.4/subprocess.py", line 859, in init restore_signals, start_new_session) File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper'

The original code worked fine this error comes from the latest code (0.2.2), any ideas?

Betree commented 7 years ago

BluePy new version somehow broke some stuff. This may be related to #10 .

Please try this and let me know if it doesn't solve the problem : On most Debian systems :

sudo apt-get install libglib2.0-dev
sudo pip3 install bluepy
sudo pip3 install git+https://github.com/Betree/pyMagicBlue.git

For Fedora :

sudo dnf install glib2-devel
sudo pip3 install bluepy
sudo pip3 install git+https://github.com/Betree/pyMagicBlue.git
IzzyWizzy666 commented 7 years ago

Same Error as all dependencies are already at the correct level.

pi@RPI3:~ $ sudo apt-get install libglib2.0-dev Reading package lists... Done Building dependency tree Reading state information... Done libglib2.0-dev is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded. pi@RPI3:~ $ sudo pip3 install bluepy Requirement already satisfied: bluepy in /usr/local/lib/python3.4/dist-packages pi@RPI3:~ $ sudo pip3 install git+https://github.com/Betree/pyMagicBlue.git Collecting git+https://github.com/Betree/pyMagicBlue.git Cloning https://github.com/Betree/pyMagicBlue.git to /tmp/pip-ukv46su9-build Requirement already satisfied (use --upgrade to upgrade): magicblue==0.2.2 from git+https://github.com/Betree/pyMagicBlue.git in /usr/local/lib/python3.4/dist-packages Requirement already satisfied: bluepy in /usr/local/lib/python3.4/dist-packages (from magicblue==0.2.2) Requirement already satisfied: webcolors in /usr/local/lib/python3.4/dist-packages (from magicblue==0.2.2)

One thing I noticed if you use it in interactive shell mode it does not scan using 'ls', it immediately exits with ERROR:magicblue.magicblueshell:Unexpected error with command "ls": [Errno 2] No such file or directory: '/usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper'

bluetoothctl can see the bulbs and the gatt tool works as well

Betree commented 7 years ago

Sorry for taking so long to respond, I went in holidays and forgot about this when I came back.

Can you run pip3 show bluepy to check the version you're running on ? Mine is 1.0.5, if your version is lower can you try again by running pip3 install --upgrade bluepy first ?

IzzyWizzy666 commented 7 years ago

Hi, Good to hear from you again :), my bluepy is bluepy-1.0.5 :(  which still gives the following .... pi@raspberrypi3:~ $ sudo magicblueshellMagic Blue interactive shell v0.2.2Type "help" for a list of available commands> lsListing Bluetooth LE devices in range for 5 minutes.Press CTRL+C to stop searching.ID    Name                           Mac address--    ----                           -----------ERROR:magicblue.magicblueshell:Unexpected error with command "ls": [Errno 2] No such file or directory: '/usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper'

On Friday, 24 February 2017, 6:37, Benjamin Piouffle <notifications@github.com> wrote:

Sorry for taking so long to respond, I went in holidays and forgot about this when I came back.Can you run pip3 show bluepy to check the version you're running on ? Mine is 1.0.5, if your version is lower can you try again by running pip3 install --upgrade bluepy first ?— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Betree commented 7 years ago

Ok thanks for this. I'll have to use the same distrib you're using as this doesn't append on my Fedora 25 x64.

From your logs I assume you're running Raspbian, may I know which version ?

IzzyWizzy666 commented 7 years ago

Hi, I'm running .....Distributor ID: RaspbianDescription:    Raspbian GNU/Linux 8.0 (jessie)Release:        8.0Codename:       jessieon a Pi 3 Please let me know if you want any other info or  for me to  try anything :) Cheers

On Friday, 24 February 2017, 23:41, Benjamin Piouffle <notifications@github.com> wrote:

Ok thanks for this. I'll have to use the same distrib you're using as this doesn't append on my Fedora 25 x64.From your logs I assume you're running Raspbian, may I know which version ?— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Betree commented 7 years ago

I just tried in a VM using raspbian 8.6 x86 and wasn't able to reproduce.

However, it seems from this blog post that you're not the only one facing this issue and that it's somehow linked to bluepy not being compiled after installed.

So here's what you can try :

cd "/usr/local/lib/python3.4/dist-packages/bluepy-1.0.5-py3.4.egg/bluepy/"    
sudo make

Then try again using the bulb.

If /usr/local/lib/python3.4/dist-packages/bluepy-1.0.5-py3.4.egg/bluepy/ directory doesn't exist then try looking for it in /usr/local/lib/python3.5/dist-packages/bluepy-1.0.5-py3.5.egg/bluepy/ instead (then try using it with python3.5 - install it if necessary). If it doesn't exists either, try /usr/local/lib/python3.4/dist-packages/bluepy/bluepy-helper or /usr/local/lib/python3.5/dist-packages/bluepy/bluepy-helper.

Please tell me how that goes for you.

IzzyWizzy666 commented 7 years ago

OK, tried making bluepy and that seemed to go OK, however I get a new error ........ pi@raspberrypi3:~ $ sudo magicblueshell Magic Blue interactive shell v0.2.2 Type "help" for a list of available commands

ls Listing Bluetooth LE devices in range for 5 minutes.Press CTRL+C to stop searching. ID Name Mac address


1 LEDBLE-09E6DE78 f2:f1:09:e6:de:78 ERROR:magicblue.magicblueshell:Unexpected error with command "ls": 'NoneType' object has no attribute 'split'

So I've just started installing python3.5 as the above was on 3.4.2, I'll let you know if it works.

Betree commented 7 years ago

Ok this one seems like a bug in magicblue !

Probably comes from this line : dev_name = dev.getValueText(9).split('\x00')[0]

Either you have a new version of the bulb with major changes in API or a device around you is not broadcasting his name. Either way it shouldn't crash like that, I'm creating a different issue #12 and will fix this as soon as possible.

IzzyWizzy666 commented 7 years ago

This what I get after 'ls'...

Magic Blue interactive shell v0.2.3 Type "help" for a list of available commands

ls Listing Bluetooth LE devices in range for 5 minutes.Press CTRL+C to stop searching. ID    Name                           Mac address --    ----                           ----------- 1     LEDBLE-5D6EA3E8      c1:40:5d:6e:a3:e8 2 Flower mate                  c4:7c:8d:61:7c:2b 3 NO_NAME                    c3:50:98:31:64:f2 4     NO_NAME                    f9:b7:24:6c:64:28 5     Flower mate                  c4:7c:8d:61:81:35 6     Flower mate                    c4:7c:8d:61:a8:46 7     NO_NAME                        f9:72:f8:1e:66:f4 8     Flower mate                    c4:7c:8d:61:ac:f7

ERROR:magicblue.magicblueshell:Unexpected error with command "ls": Failed to execute mgmt cmd 'scan'

Regards,Keith