AlexLamprianidis
Hey, whenever i perform any command i get this error ``` Traceback (most recent call last): File "./switchmate.py", line 20, in <module> from docopt import docopt ImportError: No module named docopt ```
#5 · closed · 8 comments
Hey, whenever i perform any command i get this error ``` Traceback (most recent call last): File "./switchmate.py", line 20, in <module> from docopt import docopt ImportError: No module named docopt ```
Hi @alexlab963, The project uses a requirements.txt file for its dependencies via [pip](https://pip.pypa.io/en/stable/). Try running `pip install -r requirements.txt`. You may want to use a [virtualenv](https://virtualenv.pypa.io/en/stable/) as well.
Successfully installed requirements, however now i get this error ``` Scanning... Traceback (most recent call last): File "./switchmate.py", line 136, in <module> scan() File "./switchmate.py", line 114, in scan devices = scanner.scan(10.0) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 631, in scan self.start() File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 569, in start self._mgmtCmd("le on") File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 240, in _mgmtCmd "Failed to execute mgmt cmd '%s'" % (cmd)) bluepy.btle.BTLEException: Failed to execute mgmt cmd 'le on' ```
The project uses the bluepy library for bluetooth communication and it requires a bluetooth dongle that is capable of BLE (Bluetooth Low Energy). I can't help you with your specific hardware (there are too many out there for me to provide support) but I would start by making sure your bluetooth hardware works with BLE and bluepy.
@brianpeiris I ran your `pip install -r requirements.txt` but there are errors for **bluepy** `Failed building wheel for bluepy` `Command "/usr/local/Cellar/python/3.6.4_2/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-zoqcue0v/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-u1amkv9e-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-zoqcue0v/bluepy/` Then when I try to run **./switchmate.py scan** `Traceback (most recent call last): File "./switchmate.py", line 25, in <module> from docopt import docopt ImportError: No module named docopt`
@thunpisit Can you try to run `pip install -r requirements.txt` again and post the full output here?
@brianpeiris Here you go. I'm not sure is it because of my Python that I installed but it shouldn't be. I also tried manually installed with pip & pip3. ``` Collecting bluepy==1.0.5 (from -r requirements.txt (line 1)) Using cached https://files.pythonhosted.org/packages/2f/5e/b0f10966bf23b98029164d034d3fc474f1f957885e660e48d61fa462a292/bluepy-1.0.5.tar.gz Requirement already satisfied: docopt==0.6.2 in /usr/local/lib/python3.6/site-packages (from -r requirements.txt (line 2)) Requirement already satisfied: tabulate==0.8.2 in /usr/local/lib/python3.6/site-packages (from -r requirements.txt (line 3)) Building wheels for collected packages: bluepy Running setup.py bdist_wheel for bluepy ... error Complete output from command /usr/local/Cellar/python/3.6.4_2/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-u_vwqsju/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/tmpv1fg6tkxpip-wheel- --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib creating build/lib/bluepy copying bluepy/blescan.py -> build/lib/bluepy copying bluepy/btle.py -> build/lib/bluepy copying bluepy/__init__.py -> build/lib/bluepy copying bluepy/get_services.py -> build/lib/bluepy copying bluepy/sensortag.py -> build/lib/bluepy copying bluepy/uuids.json -> build/lib/bluepy copying bluepy/bluez-src.tgz -> build/lib/bluepy copying bluepy/bluepy-helper.c -> build/lib/bluepy copying bluepy/Makefile -> build/lib/bluepy installing to build/bdist.macosx-10.13-x86_64/wheel running install Working dir is /private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-u_vwqsju/bluepy execute make -C ./bluepy clean execute make -C bluepy Failed to compile bluepy-helper. Exiting install. Command was 'make -C bluepy' in /private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-u_vwqsju/bluepy Return code was 2 Output was: b"tar xzf bluez-src.tgz\ntouch ./bluez-5.29/lib/bluetooth.c ./bluez-5.29/lib/hci.c ./bluez-5.29/lib/sdp.c ./bluez-5.29/lib/uuid.c ./bluez-5.29/attrib/att.c ./bluez-5.29/attrib/gatt.c ./bluez-5.29/attrib/gattrib.c ./bluez-5.29/attrib/utils.c ./bluez-5.29/btio/btio.c ./bluez-5.29/src/log.c ./bluez-5.29/src/shared/mgmt.c ./bluez-5.29/src/shared/crypto.c ./bluez-5.29/src/shared/att.c ./bluez-5.29/src/shared/queue.c ./bluez-5.29/src/shared/util.c ./bluez-5.29/src/shared/io-glib.c ./bluez-5.29/src/shared/timeout-glib.c\nmake: pkg-config: Command not found\nmake: pkg-config: Command not found\ngcc -L. -Os -g -Wall -Werror -DHAVE_CONFIG_H -I./bluez-5.29/attrib -I./bluez-5.29 -I./bluez-5.29/lib -I./bluez-5.29/src -I./bluez-5.29/gdbus -I./bluez-5.29/btio -o bluepy-helper bluepy-helper.c ./bluez-5.29/lib/bluetooth.c ./bluez-5.29/lib/hci.c ./bluez-5.29/lib/sdp.c ./bluez-5.29/lib/uuid.c ./bluez-5.29/attrib/att.c ./bluez-5.29/attrib/gatt.c ./bluez-5.29/attrib/gattrib.c ./bluez-5.29/attrib/utils.c ./bluez-5.29/btio/btio.c ./bluez-5.29/src/log.c ./bluez-5.29/src/shared/mgmt.c ./bluez-5.29/src/shared/crypto.c ./bluez-5.29/src/shared/att.c ./bluez-5.29/src/shared/queue.c ./bluez-5.29/src/shared/util.c ./bluez-5.29/src/shared/io-glib.c ./bluez-5.29/src/shared/timeout-glib.c \nbluepy-helper.c:33:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/lib/bluetooth.c:38:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/lib/hci.c:44:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/lib/sdp.c:45:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/lib/uuid.c:33:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\n./bluez-5.29/attrib/att.c:33:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/attrib/gatt.c:32:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/attrib/gattrib.c:34:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/attrib/utils.c:30:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/btio/btio.c:37:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/src/log.c:32:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/mgmt.c:33:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/crypto.c:33:\n./bluez-5.29/src/shared/util.h:27:10: fatal error: 'byteswap.h' file not found\n#include <byteswap.h>\n ^~~~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/att.c:34:\n./bluez-5.29/src/shared/util.h:27:10: fatal error: 'byteswap.h' file not found\n#include <byteswap.h>\n ^~~~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/queue.c:28:\n./bluez-5.29/src/shared/util.h:27:10: fatal error: 'byteswap.h' file not found\n#include <byteswap.h>\n ^~~~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/util.c:38:\n./bluez-5.29/src/shared/util.h:27:10: fatal error: 'byteswap.h' file not found\n#include <byteswap.h>\n ^~~~~~~~~~~~\n1 error generated.\n./bluez-5.29/src/shared/io-glib.c:30:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/src/shared/timeout-glib.c:22:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\nmake: *** [bluepy-helper] Error 1\n" ---------------------------------------- Failed building wheel for bluepy Running setup.py clean for bluepy Failed to build bluepy Installing collected packages: bluepy Running setup.py install for bluepy ... error Complete output from command /usr/local/Cellar/python/3.6.4_2/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-u_vwqsju/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-6z2t5_ip-record/install-record.txt --single-version-externally-managed --compile: running install Working dir is /private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-u_vwqsju/bluepy execute make -C ./bluepy clean execute make -C bluepy Failed to compile bluepy-helper. Exiting install. Command was 'make -C bluepy' in /private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-u_vwqsju/bluepy Return code was 2 Output was: b"tar xzf bluez-src.tgz\ntouch ./bluez-5.29/lib/bluetooth.c ./bluez-5.29/lib/hci.c ./bluez-5.29/lib/sdp.c ./bluez-5.29/lib/uuid.c ./bluez-5.29/attrib/att.c ./bluez-5.29/attrib/gatt.c ./bluez-5.29/attrib/gattrib.c ./bluez-5.29/attrib/utils.c ./bluez-5.29/btio/btio.c ./bluez-5.29/src/log.c ./bluez-5.29/src/shared/mgmt.c ./bluez-5.29/src/shared/crypto.c ./bluez-5.29/src/shared/att.c ./bluez-5.29/src/shared/queue.c ./bluez-5.29/src/shared/util.c ./bluez-5.29/src/shared/io-glib.c ./bluez-5.29/src/shared/timeout-glib.c\nmake: pkg-config: Command not found\nmake: pkg-config: Command not found\ngcc -L. -Os -g -Wall -Werror -DHAVE_CONFIG_H -I./bluez-5.29/attrib -I./bluez-5.29 -I./bluez-5.29/lib -I./bluez-5.29/src -I./bluez-5.29/gdbus -I./bluez-5.29/btio -o bluepy-helper bluepy-helper.c ./bluez-5.29/lib/bluetooth.c ./bluez-5.29/lib/hci.c ./bluez-5.29/lib/sdp.c ./bluez-5.29/lib/uuid.c ./bluez-5.29/attrib/att.c ./bluez-5.29/attrib/gatt.c ./bluez-5.29/attrib/gattrib.c ./bluez-5.29/attrib/utils.c ./bluez-5.29/btio/btio.c ./bluez-5.29/src/log.c ./bluez-5.29/src/shared/mgmt.c ./bluez-5.29/src/shared/crypto.c ./bluez-5.29/src/shared/att.c ./bluez-5.29/src/shared/queue.c ./bluez-5.29/src/shared/util.c ./bluez-5.29/src/shared/io-glib.c ./bluez-5.29/src/shared/timeout-glib.c \nbluepy-helper.c:33:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/lib/bluetooth.c:38:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/lib/hci.c:44:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/lib/sdp.c:45:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/lib/uuid.c:33:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\n./bluez-5.29/attrib/att.c:33:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/attrib/gatt.c:32:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/attrib/gattrib.c:34:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/attrib/utils.c:30:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/btio/btio.c:37:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/src/log.c:32:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/mgmt.c:33:\n./bluez-5.29/lib/bluetooth.h:36:10: fatal error: 'endian.h' file not found\n#include <endian.h>\n ^~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/crypto.c:33:\n./bluez-5.29/src/shared/util.h:27:10: fatal error: 'byteswap.h' file not found\n#include <byteswap.h>\n ^~~~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/att.c:34:\n./bluez-5.29/src/shared/util.h:27:10: fatal error: 'byteswap.h' file not found\n#include <byteswap.h>\n ^~~~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/queue.c:28:\n./bluez-5.29/src/shared/util.h:27:10: fatal error: 'byteswap.h' file not found\n#include <byteswap.h>\n ^~~~~~~~~~~~\n1 error generated.\nIn file included from ./bluez-5.29/src/shared/util.c:38:\n./bluez-5.29/src/shared/util.h:27:10: fatal error: 'byteswap.h' file not found\n#include <byteswap.h>\n ^~~~~~~~~~~~\n1 error generated.\n./bluez-5.29/src/shared/io-glib.c:30:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\n./bluez-5.29/src/shared/timeout-glib.c:22:10: fatal error: 'glib.h' file not found\n#include <glib.h>\n ^~~~~~~~\n1 error generated.\nmake: *** [bluepy-helper] Error 1\n" ---------------------------------------- Command "/usr/local/Cellar/python/3.6.4_2/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-u_vwqsju/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-6z2t5_ip-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/4d/tt4t_0fn7lz7wjf04hvvh6gc0000gn/T/pip-build-u_vwqsju/bluepy/ ```
@thunpisit Looks like you haven't installed the prerequisites for bluepy. You can find the relevant `apt-get install` command here: https://github.com/IanHarvey/bluepy/#installation
Thanks @brianpeiris I've done that and the bluepy error are gone but when I ran command `./switchmate.py scan` This is the output of it but I already ran requirements and docopt is already installed `Traceback (most recent call last): File "./switchmate.py", line 25, in <module> from docopt import docopt ImportError: No module named docopt`