Issue
Now Google Colaboratory supports Python2 and Python3 kernels. Can I add a Go kernel so that I can use Go in Colab too?
I found a few examples here, but it only has JavaScript and R, not for Go language.
Solution
Use this notebook, which you can remember easily with the shortcut bit.ly/colabgo
or colab.to/golang
.
Previous methods depend on having 2 notebooks, one for installation, the other for running. Now both tasks must be done in the same notebook above.
The notebook specify gophernotes
as the kernel. At first it cannot be found, so Colab will default to python3
. Just run the first cell, which will install gophernotes for you.
When the first cell finish, reload the browswer (Ctrl+R or use MENU). Colab will now find gophernotes. It can now run golang in any cell, except the first (which is python..ish).
Here's the code of the first cell, for reference. You cannot use this in a new Python notebook, because there is no way to change kernel to gophernotes
. You can only do that by text editor, or copying another notebook.
!apt install golang-go libzmq3-dev
%env GOPATH=/root/go
!go get -u github.com/gopherdata/gophernotes
!cp ~/go/bin/gophernotes /usr/bin/
!mkdir /usr/local/share/jupyter/kernels/gophernotes
!cp ~/go/src/github.com/gopherdata/gophernotes/kernel/* \
/usr/local/share/jupyter/kernels/gophernotes
Answered By - korakot
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.