Page 1 of 1

Jupyter kernel for micropython

Posted: Wed Oct 07, 2015 1:00 am
by tdabboud
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

Re: Jupyter kernel for micropython

Posted: Wed Oct 07, 2015 5:37 am
by dhylands
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

Re: Jupyter kernel for micropython

Posted: Wed Oct 07, 2015 5:11 pm
by pfalcon
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).

Re: Jupyter kernel for micropython

Posted: Wed Oct 07, 2015 10:15 pm
by tdabboud
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.

Re: Jupyter kernel for micropython

Posted: Wed Oct 07, 2015 11:03 pm
by tdabboud
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