Jupyter Notebook and CircuitPython

Today I learned that CircuitPython (from @adafruit) is available as a kernel for Jupyter Notebook so I had to try it out!

Installation on Windows 10

There is a tutorial on the Adafruit website that details how to install CircuitPython as a jupyter kernel. It uses the Anaconda distribution – which is not what I have installed on my computer. So I went a bit on my own.

Virtual Environment

First I created my virtual environment. I have a few python versions pre-installed which forces me to be explicit when choosing which version. Most people would only need to type python3

 python3.6.64 -m venv circuitpython

Preparing to activate the virtual environment:

cd circuitpython\Scripts

Activating is simple now.

activate

Installing Jupyter

Now that the virtual environment is active we need to install the Jupyter files. This process takes a bit of time but is quite painless on the user.

python -m pip install jupyter 

Installing the circuitpython kernel

Go to the Adafruit Github and download the latest circuitpython kernel release. Unless you want to experiment, it’s best to avoid the beta release and go with the latest release tag. As of the time of writing this post, it’s version 0.3.2

Scroll to the Assets section and download the zip file (or the other one if you prefer, whatever your computer can handle).

Unzip the file and place its content (a folder named circuitpython_kernel-master) into the circuitpython folder we created previously. cd into this new folder to install the kernel.

Following the Adafruit tutorial, now the two following commands are needed:

python setup.py install
python -m circuitpython_kernel.install

The following allows you to verify that all is good

jupyter kernelspec list

Installing CircuitPython on the CircuitPlaygroundExpress

If it’s not already done, CircuitPython needs to be installed on whatever board you have on hand. I happen to have a Circuit Playground Express.
Follow the tutorial to set your board into bootloader mode to transfer circuitpython.

Grab the appropriate file from Adafruit Github.  Look for the latest release and the assets for that specific release. I drop it directly onto the CPLAYBOOT drive.

Starting the Notebook

Typing jupyter notebook from my circuitpython folder will start up the kernel and launch my browser. YES! Let’s go into circuitpython_kernel-master/examples and run the CPX_Blinka notebook as per the Adafruit tutorial

Top right arrow does indicate the circuitpython kernel, and the numbers next to the cells show a successful run! ( I did a run all cells to get here)

At this point I have interactive python on my circuitplayground! Woohoo!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s