Jupyter notebook keeps on reconnecting to kernel because of tornado

Recently after I upgraded jupyter notebook on my anaconda distribution, it stops working. Every time it opens a python notebook, it keeps on showing “connecting to kernel” on the top right. The console shows the following error message:

[E 15:45:52.335 NotebookApp] Uncaught exception in /api/kernels/1633c355-600d-4653-b7fd-048fc1697007/channels
 Traceback (most recent call last):
 File "C:\Users\TABLET0006\Anaconda3\lib\site-packages\tornado\websocket.py", line 498, in _run_callback
 result = callback(*args, **kwargs)
 File "C:\Users\TABLET0006\Anaconda3\lib\site-packages\notebook\services\kernels\handlers.py", line 262, in open
 super(ZMQChannelsHandler, self).open()
 File "C:\Users\TABLET0006\Anaconda3\lib\site-packages\notebook\base\zmqhandlers.py", line 176, in open
 self.send_ping, self.ping_interval, io_loop=loop,
 TypeError: __init__() got an unexpected keyword argument 'io_loop'

I searched online, and found that tornado may cause the issues:


So I decided to downgrade tornado to 4.4.3 and it fixed my probem. To downgrade tornado. First, open Anaconda Prompt or your command prompt with python, and type the following:

pip install --ignore-installed tornado=4.4.3




Installing dbus on Mac OS using Brew

To install dbus, I follow the steps here: http://brewinstall.org/install-dbus-on-mac-with-brew/

  • First, open Terminal
  • Run the following command on the terminal:
  • ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
  • Then you need to install Xcode command line tools:

xcode-select –install

  • After that, run brew:

brew install dbus

Running Thymio Wireless with Python on Ubuntu Virtual Machine

I have written a post on running Thymio using Raspberry Pi. Somehow the wireless connection was not working for me even after I plug the usb wifi. So I decided to try using Ubuntu Virtual Machine on Windows host. And it works.


  • Host OS: Windows 10
  • VirtualBox
  • Virtual Machine OS: Ubuntu 16.04 LTS

After finish installing Ubuntu on the VirtualBox. These are the steps:

  1. Install aseba following the steps here. The official documentation provides steps for Ubuntu.
  2. Install dbus: sudo apt-get install python-dbus
  3. Install gobject: sudo apt-get install python-gobject

Now you can follow the steps to run the python code:

  1. run asebamedulla: sudo asebamedulla “ser:name=Thymio-II”
  2. run python code on a different terminal: sudo python pithymio.py

Running Python on Thymio

I found a link that describes the process here:


The setup that I use is Raspberry Pi 2 Model B+ running Jessie. First we need to setup the hardware connection:

  1. Connect USB from Pi to Thymio
  2. Connect power from socket to Pi
  3. Start Pi

Now, we need to install some software. There is a bug in the software provided by Thymio websites, so I found a forum where they provided the fix for Pi. On your pi, open terminal, and type the following:

sudo apt-get install apt-transport-https

This is to enable apt-get to get source from https.


Now, we add the source by editing /etc/apt/sources.list:

sudo sh -c 'echo "deb https://dl.bintray.com/msprunck/Aseba jessie main" | sudo tee -a /etc/apt/sources.list'
sudo apt-get update
sudo apt-get install libenki libdashel aseba

After it is installed, we can test if asebamedulla is running. To do this, open a new terminal, and type:

sudo asebamedulla "ser:name=Thymio-II"

If it works, it will output something like the following:

Found Thymio-II on port /dev/ttyACM0

Now, download the sample code. Open a new terminal or a new tab, and run the sample code as follows:

sudo python pithymio.py

It will output:

dbus.Array([dbus.STring(u'thymio-II')], signature=dbus.Signature('s'))
0 0 0 0 0

At this point, it waits for you to enter the command.

  • Type “w” and press Enter to move forward for 1 second.
  • Type “s” and press Enter to move backward for 1 second.
  • Type “a” to rotate to left
  • Type “d” to rotate to right

Type CTRL-C to exit.


Installing zenburn theme on Aquamacs

I followed the steps in https://github.com/bbatsov/zenburn-emacs to install zenburn theme using MELPA. But I had difficulty making it stick the next time it loads. These are the steps that works with me:

  1. Run Aquamacs
  2. Type: M-x package-install zenburn-theme
  3. I also added (load-theme ‘zenburn t) to “~/Library/Preferences/Aquamacs Emacs/Preferences.el”

But when I close and run Aquamacs again it is not exactly zenburn as the lower bar text are too dark. So I need to load the theme manually:

M-x load-theme zenburn

To make it stick, I follow the steps in: https://www.emacswiki.org/emacs/AquamacsFAQ#toc21

  1. With zenburn theme loaded, I go to: Menu -> Options → Appearance → Auto Faces → Use Current Face as Default
  2. And I do the next step: Menu → Options → Appearance → Adopt Face and Frame Parameters as Default
  3. Answer “Yes” to the dialog.
  4. Exit Aquamacs and “Y” to save the settings.

Multiple LDAP authentication in Django

Django allows multiple LDAP configuration. The example of the configuration is given here: https://pythonhosted.org/django-auth-ldap/multiconfig.html

To do this we need to create a Python module under site-packages. For example we can create a module called ‘mypackage’.

$ ls /home/administrator/websenv/lib/python2.7/site-packages/mypackage
__init__.py ldap.py

We can leave __init__.py empty, and write the following entry into ldap.py:

from django_auth_ldap.backend import LDAPBackend

class LDAPBackend1(LDAPBackend):

class LDAPBackend2(LDAPBackend):

class LDAPBackend3(LDAPBackend):

Now, we can configure the ldap in Django settings.py. This is an example of a configuration in Django.

import ldap
from django_auth_ldap.config import LDAPSearch


AUTH_LDAP_2_SERVER_URI = "ldap://student.myschool.edu.sg"
AUTH_LDAP_3_SERVER_URI = "ldap://stafff.myschool.edu.sg"
AUTH_LDAP_1_SERVER_URI = "ldap://"

AUTH_LDAP_2_USER_DN_TEMPLATE = "%(user)s@student.myschool.edu.sg"
AUTH_LDAP_3_USER_DN_TEMPLATE = "%(user)s@staff.myschool.edu.sg"
AUTH_LDAP_1_USER_DN_TEMPLATE = "%(user)s@myschool.edu.sg"


In the example above, we created three backends LDAP1, 2, and 3. We first import the backends to Django and set the URI, DN_TEMPLATE, and bind the domain.

We may need to restart Django and the server:

$python manage.py syncdb
$sudo apachectl restart

Erasing External Harddisk that cannot be opened

I got problem with my external hard disk. After some issues of umounting the disk, I couldn’t open the hard disk anymore. I tried to use Disk Util to repair, but it said it cannot be repaired and must be erased. But I can’t even erased it! It says disk can’t be opened. So I finally managed to erase it.

First, go to Terminal and type:

$ diskutil list

This will show a list of disk and partition. It happens that I can’t seem to erase the volume. But somehow I can erase the disk. So this what I do.

$ diskutil unmountDisk force /dev/disk1

and after it unmount, I type:

$ diskutil eraseDisk JHFS+ Backup /dev/disk1
Started erase on disk1
Unmounting disk
Creating the partition map
Waiting for the disks to reappear
Formatting disk1s2 as Mac OS Extended (Journaled) with name Backup
Initialized /dev/rdisk1s2 as a 931 GB case-insensitive HFS Plus volume with a 81920k journal
Mounting disk
Finished erase on disk1