Please make sure to have followed the Python 2 tutorial first as we will only quickly brush on Python 3.
You should have Python3 and pip3 installed. Our Python SDK and example scripts work in Python3 and Python2.
You can check with:
>>> which python3 >>> python3 --version >>> pip3 --version
4.2.1. Install Python and Pip¶
If you need to install python3, use the command:
>>> sudo apt-get install python3.6
If you need to install pip3, use the command:
>>> sudo apt install python3-pip
You can also use your distribution’s package manager to install these.
4.2.2. Install MetaWear¶
Use pip to install the metawear package. It depends on pygattlib so ensure your Linux environment first has the necessary dependencies installed.
>>> pip3 install metawear
You may or may not need/want to use sudo.
4.3. Run Script¶
Now let’s run our scan_connect script using Python3:
>>> sudo python3 scan_connect.py
Let’s connect to my nearby MetaMotionC and toggle the led:
>>> sudo python3 led.py D7:83:B0:4D:D4:1B
Last but not least, let’s stream some accelerometer data:
>>> sudo python3 stream_acc.py D7:83:B0:4D:D4:1B
4.4. Learn More¶
Please refer back to the Python2 section and our developer documentation to continue developing your python scripts.