Jupyter kernel for micropython

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
tdabboud
Posts: 4
Joined: Wed Oct 07, 2015 12:50 am

Jupyter kernel for micropython

Post by tdabboud » Wed Oct 07, 2015 1:00 am

I have developed a Jupyter/Ipython kernel module for use with micropython. I got inspiration to do this from http://forum.micropython.org/viewtopic.php?f=15&t=629, as the code was never released and I thought it was a very interesting project. I currently have full support for the unix port and have a very rough prototype of the stmhal port working. For the stmhal port, I am using the tools/pyboard.py to interface with the microcontroller. This is still very unstable as I am running python in the notebook and that calls out to the pyboard module, which in turn talks to the board. I want to make it seamless for the user to open a notebook and they can immediately start interacting with the board.

You can get the code from my github. Feel free to contribute or post any issues you encounter. Also, I would appreciate any feedback.

https://github.com/TDAbboud/mpkernel

User avatar
dhylands
Posts: 3385
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Jupyter kernel for micropython

Post by dhylands » Wed Oct 07, 2015 5:37 am

Does this require a particular version of python or ipython?

I'm using Ubuntu 14.04 and when I tried sudo make install, I get this at the end:

Code: Select all

running install_egg_info
removing '/usr/local/lib/python2.7/dist-packages/mpkernel-0.8900.egg-info' (and everything under it)
Copying mpkernel.egg-info to /usr/local/lib/python2.7/dist-packages/mpkernel-0.8900.egg-info
Traceback (most recent call last):
  File "setup.py", line 121, in <module>
    'License :: OSI Approved :: MIT License'
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 48, in run
    from IPython.kernel.kernelspec import install_kernel_spec
ImportError: No module named kernelspec
make: *** [install] Error 1

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Jupyter kernel for micropython

Post by pfalcon » Wed Oct 07, 2015 5:11 pm

tdabboud wrote:I have developed a Jupyter/Ipython kernel module for use with micropython.

https://github.com/TDAbboud/mpkernel
Thanks for coming up with this. I didn't give it a try, but from looking at README:
Unix port

You must set the environment variable for the unix micropython:

$ export MPUNIX=<PATH_TO_UNIX_MICROPYTHON>
I'd suggest to either remove that, or at least make optional. You should just expect micropython to be in PATH (and tell users to put it there).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

tdabboud
Posts: 4
Joined: Wed Oct 07, 2015 12:50 am

Re: Jupyter kernel for micropython

Post by tdabboud » Wed Oct 07, 2015 10:15 pm

Unix port

You must set the environment variable for the unix micropython:

$ export MPUNIX=<PATH_TO_UNIX_MICROPYTHON>
I'd suggest to either remove that, or at least make optional. You should just expect micropython to be in PATH (and tell users to put it there).
That's a good idea. I will make this an optional value, and assume that the path to the unix micropython is in PATH.

tdabboud
Posts: 4
Joined: Wed Oct 07, 2015 12:50 am

Re: Jupyter kernel for micropython

Post by tdabboud » Wed Oct 07, 2015 11:03 pm

dhylands wrote:Does this require a particular version of python or ipython?

I'm using Ubuntu 14.04 and when I tried sudo make install, I get this at the end:

Code: Select all

running install_egg_info
removing '/usr/local/lib/python2.7/dist-packages/mpkernel-0.8900.egg-info' (and everything under it)
Copying mpkernel.egg-info to /usr/local/lib/python2.7/dist-packages/mpkernel-0.8900.egg-info
Traceback (most recent call last):
  File "setup.py", line 121, in <module>
    'License :: OSI Approved :: MIT License'
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 48, in run
    from IPython.kernel.kernelspec import install_kernel_spec
ImportError: No module named kernelspec
make: *** [install] Error 1
I am using the Jupyter client(1.0.0) instead of the Ipython package, but I believe you can use Ipython>=3.x. I recommend just to pip install Jupyter. As for python, I have been using 3.4 and have not tested it completely using 2.7. I just tested the install on ubuntu in a virtualenv using the following commands and it worked:

Code: Select all

mkvirtualenv mpkernel
pip install jupyter
pip install pyserial
make install

Post Reply