{"id":13425063,"url":"https://github.com/gopherdata/gophernotes","last_synced_at":"2025-04-11T03:32:52.649Z","repository":{"id":40336194,"uuid":"50202460","full_name":"gopherdata/gophernotes","owner":"gopherdata","description":"The Go kernel for Jupyter notebooks and nteract.","archived":false,"fork":false,"pushed_at":"2023-11-03T18:02:49.000Z","size":21638,"stargazers_count":3915,"open_issues_count":52,"forks_count":261,"subscribers_count":81,"default_branch":"master","last_synced_at":"2025-04-10T15:07:32.388Z","etag":null,"topics":["artificial-intelligence","data-science","go","golang","gophernotes","jupyter","jupyter-notebook","kernel","machine-learning","nteract","numerical-methods","zeromq"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gopherdata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null}},"created_at":"2016-01-22T19:22:16.000Z","updated_at":"2025-04-10T11:40:47.000Z","dependencies_parsed_at":"2024-05-21T05:45:33.796Z","dependency_job_id":"6c4abba7-5a0a-43e6-89f4-bc1bc41cdcb8","html_url":"https://github.com/gopherdata/gophernotes","commit_stats":{"total_commits":325,"total_committers":30,"mean_commits":"10.833333333333334","dds":0.5169230769230769,"last_synced_commit":"a9770e95869c53c347786d7323ff18be0b16205f"},"previous_names":["gophergala2016/gophertunes","gopherds/gophernotes","gophergala2016/gophernotes"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gopherdata%2Fgophernotes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gopherdata%2Fgophernotes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gopherdata%2Fgophernotes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gopherdata%2Fgophernotes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gopherdata","download_url":"https://codeload.github.com/gopherdata/gophernotes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248335500,"owners_count":21086603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","data-science","go","golang","gophernotes","jupyter","jupyter-notebook","kernel","machine-learning","nteract","numerical-methods","zeromq"],"created_at":"2024-07-31T00:01:03.697Z","updated_at":"2025-04-11T03:32:52.617Z","avatar_url":"https://github.com/gopherdata.png","language":"Go","readme":"![alt tag](files/gophernotes-logo.png)\n\n[![Build Status](https://travis-ci.org/gopherdata/gophernotes.svg?branch=master)](https://travis-ci.org/gopherdata/gophernotes)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/gopherdata/gophernotes/blob/master/LICENSE)\n\n# gophernotes - Use Go in Jupyter notebooks and nteract\n\n`gophernotes` is a Go kernel for [Jupyter](http://jupyter.org/) notebooks and [nteract](https://nteract.io/).  It lets you use Go interactively in a browser-based notebook or desktop app.  Use `gophernotes` to create and share documents that contain live Go code, equations, visualizations and explanatory text.  These notebooks, with the live Go code, can then be shared with others via email, Dropbox, GitHub and the [Jupyter Notebook Viewer](http://nbviewer.jupyter.org/). Go forth and do data science, or anything else interesting, with Go notebooks!\n\n**Acknowledgements** - This project utilizes a Go interpreter called [gomacro](https://github.com/cosmos72/gomacro) under the hood to evaluate Go code interactively. The gophernotes logo was designed by the brilliant [Marcus Olsson](https://github.com/marcusolsson) and was inspired by Renee French's original Go Gopher design.\n\n- [Examples](#examples)\n- Install gophernotes:\n  - [Prerequisites](#prerequisites)\n  - [FreeBSD](#linux-or-freebsd)\n  - [Linux](#linux-or-freebsd)\n  - [Mac](#mac)\n  - [Windows](#windows)\n  - [Docker](#docker)\n- [Getting Started](#getting-started)\n- [Limitations](#limitations)\n- [Troubleshooting](#troubleshooting)\n\n## Examples\n\n### Jupyter Notebook:\n\n![](files/jupyter.gif)\n\n### nteract:\n\n![](files/nteract.gif)\n\n### Example Notebooks (download and run them locally, follow the links to view in Github, or use the [Jupyter Notebook Viewer](http://nbviewer.jupyter.org/)):\n- [Worker Pools](examples/Worker_Pools.ipynb)\n- [Matrix Operations](examples/Matrix_Operations.ipynb)\n- [Facial Recognition](examples/Facial_Recognition_MachineBox.ipynb)\n- [Display Images, HTML, LaTeX...](examples/Display.ipynb)\n\n## Installation\n\n### Prerequisites\n\n- [Go 1.13+](https://golang.org/doc/install) - including GOPATH/bin added to your PATH (i.e., you can run Go binaries that you `go install`).\n- [Jupyter Notebook](http://jupyter.readthedocs.io/en/latest/install.html) or [nteract](https://nteract.io/desktop)\n- [git](https://git-scm.com/download) - usually already present on Linux and Mac OS X. If not present, follow the instructions at [https://git-scm.com/download](https://git-scm.com/download)\n\n### Linux or FreeBSD\n\nThe instructions below should work both on Linux and on FreeBSD.\n\nMethod 1: quick installation as module\n```sh\n  go install github.com/gopherdata/gophernotes@v0.7.5\n  mkdir -p ~/.local/share/jupyter/kernels/gophernotes\n  cd ~/.local/share/jupyter/kernels/gophernotes\n  cp \"$(go env GOPATH)\"/pkg/mod/github.com/gopherdata/gophernotes@v0.7.5/kernel/*  \".\"\n  chmod +w ./kernel.json # in case copied kernel.json has no write permission\n  sed \"s|gophernotes|$(go env GOPATH)/bin/gophernotes|\" \u003c kernel.json.in \u003e kernel.json\n```\n\nMethod 2: manual installation from GOPATH\n```sh\n  mkdir -p \"$(go env GOPATH)\"/src/github.com/gopherdata\n  cd \"$(go env GOPATH)\"/src/github.com/gopherdata\n  git clone https://github.com/gopherdata/gophernotes\n  cd gophernotes\n  git checkout -f v0.7.5\n  go install\n  mkdir -p ~/.local/share/jupyter/kernels/gophernotes\n  cp kernel/* ~/.local/share/jupyter/kernels/gophernotes\n  cd ~/.local/share/jupyter/kernels/gophernotes\n  chmod +w ./kernel.json # in case copied kernel.json has no write permission\n  sed \"s|gophernotes|$(go env GOPATH)/bin/gophernotes|\" \u003c kernel.json.in \u003e kernel.json\n```\n\nTo confirm that the `gophernotes` binary is installed in GOPATH, execute it directly:\n```sh\n  \"$(go env GOPATH)\"/bin/gophernotes\n```\nand you should see the following:\n```sh\n2017/09/20 10:33:12 Need a command line argument specifying the connection file.\n```\n\n**Note** - if you have the `JUPYTER_PATH` environmental variable set or if you are using an older version of Jupyter, you may need to copy this kernel config to another directory.  You can check which directories will be searched by executing:\n\n```sh\n  jupyter --data-dir\n```\n\n### Mac\n\n**Important Note** - gomacro relies on the `plugin` package when importing third party libraries. This package works reliably on Mac OS X with Go 1.10.2+ as long as you **never** execute the command `strip gophernotes`.\n\nMethod 1: quick installation as module\n```sh\n  go install github.com/gopherdata/gophernotes@v0.7.5\n  mkdir -p ~/Library/Jupyter/kernels/gophernotes\n  cd ~/Library/Jupyter/kernels/gophernotes\n  cp \"$(go env GOPATH)\"/pkg/mod/github.com/gopherdata/gophernotes@v0.7.5/kernel/*  \".\"\n  chmod +w ./kernel.json # in case copied kernel.json has no write permission\n  sed \"s|gophernotes|$(go env GOPATH)/bin/gophernotes|\" \u003c kernel.json.in \u003e kernel.json\n```\n\nMethod 2: manual installation from GOPATH\n```sh\n  mkdir -p \"$(go env GOPATH)\"/src/github.com/gopherdata\n  cd \"$(go env GOPATH)\"/src/github.com/gopherdata\n  git clone https://github.com/gopherdata/gophernotes\n  cd gophernotes\n  git checkout -f v0.7.5\n  go install\n  mkdir -p ~/Library/Jupyter/kernels/gophernotes\n  cp kernel/* ~/Library/Jupyter/kernels/gophernotes\n  cd ~/Library/Jupyter/kernels/gophernotes\n  chmod +w ./kernel.json # in case copied kernel.json has no write permission\n  sed \"s|gophernotes|$(go env GOPATH)/bin/gophernotes|\" \u003c kernel.json.in \u003e kernel.json\n```\n\nTo confirm that the `gophernotes` binary is installed in GOPATH, execute it directly:\n```sh\n  \"$(go env GOPATH)\"/bin/gophernotes\n```\nand you should see the following:\n```sh\n2017/09/20 10:33:12 Need a command line argument specifying the connection file.\n```\n\n**Note** - if you have the `JUPYTER_PATH` environmental variable set or if you are using an older version of Jupyter, you may need to copy this kernel config to another directory.  You can check which directories will be searched by executing:\n\n```sh\n  jupyter --data-dir\n```\n\n### Windows\n\n**Important Note** - gomacro relies on the `plugin` package when importing third party libraries.  This package is only supported on Linux and Mac OS X currently.  Thus, if you need to utilize third party packages in your Go notebooks and you are running on Windows, you should use the [Docker](#docker) install and run gophernotes/Jupyter in Docker.\n\n1. Download gophernotes inside GOPATH, compile and install it\n\n    ```\n    go env GOPATH \u003e temp.txt\n    set /p GOPATH=\u003ctemp.txt\n    mkdir %GOPATH%\\src\\github.com\\gopherdata\n    cd /d %GOPATH%\\src\\github.com\\gopherdata\n    git clone https://github.com/gopherdata/gophernotes\n    cd gophernotes\n    git checkout -f v0.7.5\n    go install\n    ```\n\n2. Copy the kernel config:\n\n    ```\n    mkdir %APPDATA%\\jupyter\\kernels\\gophernotes\n    xcopy %GOPATH%\\src\\github.com\\gopherdata\\gophernotes\\kernel %APPDATA%\\jupyter\\kernels\\gophernotes /s\n    ```\n\n    Note, if you have the `JUPYTER_PATH` environmental variable set or if you are using an older version of Jupyter, you may need to copy this kernel config to another directory.  You can check which directories will be searched by executing:\n\n    ```\n    jupyter --data-dir\n    ```\n\n3. Update `%APPDATA%\\jupyter\\kernels\\gophernotes\\kernel.json` with the FULL PATH to your gophernotes.exe (usually in %GOPATH%\\bin).  For example:\n\n    ```\n    {\n        \"argv\": [\n          \"C:\\\\gopath\\\\bin\\\\gophernotes.exe\",\n          \"{connection_file}\"\n          ],\n        \"display_name\": \"Go\",\n        \"language\": \"go\",\n        \"name\": \"go\"\n    }\n    ```\n\n### Docker\n\nYou can try out or run Jupyter + gophernotes without installing anything using Docker. To run a Go notebook that only needs things from the standard library, run:\n\n```\n  docker run -it -p 8888:8888 gopherdata/gophernotes\n```\n\nOr to run a Go notebook with access to common Go data science packages (gonum, gota, golearn, etc.), run:\n\n```\n  docker run -it -p 8888:8888 gopherdata/gophernotes:latest-ds\n```\n\nIn either case, running this command should output a link that you can follow to access Jupyter in a browser. Also, to save notebooks to and/or load notebooks from a location outside of the Docker image, you should utilize a volume mount.  For example:\n\n```\n  docker run -it -p 8888:8888 -v /path/to/local/notebooks:/path/to/notebooks/in/docker gopherdata/gophernotes\n```\n\n## Getting Started\n\n### Jupyter\n\n- If you completed one of the local installs above (i.e., not the Docker install), start the jupyter notebook server:\n\n  ```\n  jupyter notebook\n  ```\n\n- Select `Go` from the `New` drop down menu.\n\n- Have fun!\n\n### nteract\n\n- Launch nteract.\n\n- From the nteract menu select Language -\u003e Go.\n\n- Have fun!\n\n## Special commands\n\nIn addition to Go code, the following special commands are also supported - they must be on a line by their own:\n- %cd [path]\n- %go111module {on|off}\n- %help\n- $ shell_command [args...]\n\n## Limitations\n\ngophernotes uses [gomacro](https://github.com/cosmos72/gomacro) under the hood to evaluate Go code interactively. You can evaluate most any Go code with gomacro, but there are some limitations, which are discussed in further detail [here](https://github.com/cosmos72/gomacro#current-status).  Most notably, gophernotes does NOT support:\n\n- importing third party packages when running natively on Windows - This is a current limitation of the Go `plugin` package.\n- some corner cases on interpreted interfaces, as interface -\u0026gt; interface type switch and type assertion, are not implemented yet.\n- some corner cases on recursive types may not work correctly.\n- conversion from typed constant to interpreted interface is not implemented. Workaround: assign the constant to a variable, then convert the variable to the interpreted interface type.\n- conversions from/to unsafe.Pointer are not supported.\n- goto is only partially implemented.\n- out-of-order code in the same cell is supported, but not heavily tested. It has some known limitations for composite literals.\n\nAlso, creation of new named types is emulated, and their methods are visible only to interpreted code.\n\n## Troubleshooting\n\n### gophernotes not found\n\nDepending on your environment, you may need to manually change the path to the `gophernotes` executable in `kernel/kernel.json` before copying it to `~/.local/share/jupyter/kernels/gophernotes`.  You can put the **full path** to the `gophernotes` executable here, and you shouldn't have any further issues.\n\n### \"Kernel error\" in a running notebook\n\n```\nTraceback (most recent call last):\n  File \"/usr/local/lib/python2.7/site-packages/notebook/base/handlers.py\", line 458, in wrapper\n    result = yield gen.maybe_future(method(self, *args, **kwargs))\n  File \"/usr/local/lib/python2.7/site-packages/tornado/gen.py\", line 1008, in run\n    value = future.result()\n  ...\n  File \"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py\", line 1335, in _execute_child\n    raise child_exception\nOSError: [Errno 2] No such file or directory\n```\n\nStop jupyter, if it's already running.\n\nAdd a symlink to `/go/bin/gophernotes` from your path to the gophernotes executable. If you followed the instructions above, this will be:\n\n```\nsudo ln -s $HOME/go/bin/gophernotes /go/bin/gophernotes\n```\n\nRestart jupyter, and you should now be up and running.\n\n### error \"could not import C (no metadata for C)\" when importing a package\n\nAt a first analysis, it seems to be a limitation of the new import mechanism that supports Go modules.\nYou can switch the old (non module-aware) mechanism with the command `%go111module off`\n\nTo re-enable modules support, execute `%go111module on`\n\n### Look at Jupyter notebook's logs for debugging\n\nIn order to see the logs for your Jupyter notebook, use the --log-level option\n```\njupyter notebook --log-level DEBUG\n```\n","funding_links":[],"categories":["Go","Jupyter Kernels","Containers \u0026 Language Extentions \u0026 Linting","Jupyter内核","Golang","Repositories"],"sub_categories":["For Go","Plotting (exploratory and publication)","Tool"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgopherdata%2Fgophernotes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgopherdata%2Fgophernotes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgopherdata%2Fgophernotes/lists"}