Skip to content

Commit 5ebd7b0

Browse files
committed
new example and new install docs
1 parent ba012ea commit 5ebd7b0

13 files changed

+687
-1661
lines changed

README.md

+73-183
Original file line numberDiff line numberDiff line change
@@ -4,195 +4,69 @@
44

55
`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!
66

7-
This project utilizes a Go interpreter called [gomacro](https://github.com/cosmos72/gomacro) under the hood to evaluate Go code interactively.
7+
**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.
88

99
## Examples
1010

11-
Jupyter Notebook:
11+
### Jupyter Notebook:
12+
1213
![](files/jupyter.gif)
1314

14-
nteract:
15+
### nteract:
16+
1517
![](files/nteract.gif)
1618

1719
### Example Notebooks (dowload and run them locally, follow the links to view in Github, or use the [Jupyter Notebook Viewer](http://nbviewer.jupyter.org/)):
18-
- [Simple Printing and Channels](https://github.com/gopherds/gophernotes/blob/master/examples/Simple-Example.ipynb)
19-
- [Pattern Recognition with Golearn](https://github.com/gopherds/gophernotes/blob/master/examples/Pattern-Recognition.ipynb)
20-
- [Feed Forward, Recurrent Neural Nets](https://github.com/gopherds/gophernotes/blob/master/examples/Feed-Forward-Recurrent-NN.ipynb)
21-
- [Time Parsing, Formatting](https://github.com/gopherds/gophernotes/blob/master/examples/Time-Formatting-Parsing.ipynb)
22-
- [Stateful Goroutines](https://github.com/gopherds/gophernotes/blob/master/examples/Stateful-Goroutines.ipynb)
23-
- [Worker Pools](https://github.com/gopherds/gophernotes/blob/master/examples/Worker-Pools.ipynb)
20+
- [Worker Pools](examples/Worker_Pools.ipynb)
21+
- [Matrix Operations](examples/Matrix_Operations.ipynb)
22+
- [Facial Recognition](examples/Facial_Recognition_MachineBox.ipynb)
2423

2524
## Installation
2625

27-
### Docker
28-
29-
- Pull down and run the [latest image](https://hub.docker.com/r/dwhitena/gophernotes/):
30-
31-
```
32-
docker pull dwhitena/gophernotes:latest
33-
docker run --name gophernotes --net host -d dwhitena/gophernotes:latest
34-
```
35-
36-
*Possible issues* - For OSX Docker Machine / Dlite users, you may need to set the IP to `0.0.0.0` instead of the default `localhost` with:
37-
38-
```
39-
docker run -p 8888:8888 -d dwhitena/gophernotes jupyter notebook --no-browser --ip=0.0.0.0
40-
```
41-
42-
*Note* - this is a pretty large image, because it contains a full distribution of [Anaconda](http://docs.continuum.io/anaconda/index) plus the add ons of gophernotes. However, with this image, you can create Go notebooks, Python notebooks, text files, run ipython in the shell, etc.
43-
44-
### Local, Linux
45-
46-
Make sure you have the following dependencies:
47-
48-
- [Go](https://golang.org/) 1.5+
49-
- Jupyter (see [here](http://jupyter.readthedocs.org/en/latest/install.html) for more details on installing jupyter)
50-
- [ZeroMQ](http://zeromq.org/) (2.2.X or 4.x)
26+
### Prerequisites
5127

52-
Then:
53-
54-
1. Create a workspace and setup your `GOPATH`, see https://golang.org/doc/code.html#GOPATH
55-
56-
2. Install `goimports` if you haven't already:
57-
58-
```
59-
go get golang.org/x/tools/cmd/goimports
60-
```
28+
- [Go 1.9+](https://golang.org/doc/install) - including GOPATH/bin added to your PATH (i.e., you can run Go binaries that you `go install`).
29+
- [Jupyter Notebook](http://jupyter.readthedocs.io/en/latest/install.html) or [nteract](https://nteract.io/desktop)
30+
- [ZeroMQ 4.X.X](http://zeromq.org/intro:get-the-software) - for convenience, pre-built Windows binaries (v4.2.1) are included in the zmq-win directory.
6131

62-
3. Get the kernel:
63-
- with ZeroMQ 2.2.x:
32+
### Linux
6433

65-
```
66-
go get github.com/gopherds/gophernotes
67-
```
68-
69-
- with ZeroMQ 4.x:
70-
71-
```
72-
go get -tags zmq_4_x github.com/gopherds/gophernotes
73-
```
74-
75-
4. Create a directory for the new kernel config:
76-
77-
```
78-
mkdir -p ~/.local/share/jupyter/kernels/gophernotes
79-
```
80-
81-
Note, depending on which version of jupyter you are using and if you are using Anaconda, you may need to copy to `~/.ipython` rather than `~/.local/share`:
82-
83-
```
84-
mkdir ~/.ipython/kernels/gophernotes
85-
cp -r $GOPATH/src/github.com/gopherds/gophernotes/kernel/* ~/.ipython/kernels/gophernotes/
86-
```
87-
5. Copy the kernel config into the `~/.local/jupyter` directory:
88-
89-
```
90-
cp -r $GOPATH/src/github.com/gopherds/gophernotes/kernel/* ~/.local/share/jupyter/kernels/gophernotes
91-
```
92-
93-
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:
94-
95-
```
96-
jupyter --data-dir
97-
```
98-
99-
### Local, OSX
100-
101-
Make sure you have the following dependencies:
102-
103-
- [Go](https://golang.org/) 1.5+
104-
- Jupyter (see [here](http://jupyter.readthedocs.org/en/latest/install.html) for more details on installing jupyter)
105-
- [ZeroMQ](http://zeromq.org/) (2.2.X or 4.x)
106-
107-
Then:
108-
109-
1. Install goimports, if not already installed:
110-
111-
```
112-
go get golang.org/x/tools/cmd/goimports
113-
```
114-
115-
2. Install gophernotes:
116-
- with ZeroMQ 2.2.x:
117-
118-
```
119-
go get github.com/gopherds/gophernotes
120-
```
121-
122-
- with ZeroMQ 4.x:
34+
```sh
35+
$ go install github.com/gopherdata/gophernotes
36+
$ mkdir -p ~/.local/share/jupyter/kernels/gophernotes
37+
$ cp $GOPATH/src/github.com/gopherdata/gophernotes/kernel/* ~/.local/share/jupyter/kernels/gophernotes
38+
```
12339

124-
```
125-
go get -tags zmq_4_x github.com/gopherds/gophernotes
126-
```
127-
128-
- if you get this error:
129-
130-
```
131-
# pkg-config --cflags libzmq libzmq libzmq libzmq
132-
Package libzmq was not found in the pkg-config search path.
133-
Perhaps you should add the directory containing `libzmq.pc'
134-
to the PKG_CONFIG_PATH environment variable
135-
No package 'libzmq' found
136-
```
137-
138-
then:
139-
140-
```
141-
export PKG_CONFIG_PATH=/usr/local/Cellar/zeromq22/lib/pkgconfig/
142-
```
40+
To confirm that the `gophernotes` binary is installed and in your PATH, you should see the following when running `gophernotes` directly:
14341

144-
3. Copy the kernel config:
42+
```sh
43+
$ gophernotes
44+
2017/09/20 10:33:12 Need a command line argument specifying the connection file.
45+
```
14546

146-
```
147-
mkdir -p ~/Library/Jupyter/kernels/gophernotes
148-
cp -r $GOPATH/src/github.com/gopherds/gophernotes/kernel/* ~/Library/Jupyter/kernels/gophernotes
149-
```
150-
151-
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:
47+
**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:
15248

153-
```
154-
jupyter --data-dir
155-
```
156-
157-
4. Update `~/Library/Jupyter/kernels/gophernotes/kernel.json` with the FULL PATH to your gophernotes binary (in $GOPATH/bin). For example:
49+
```sh
50+
$ jupyter --data-dir
51+
```
15852

159-
```
160-
{
161-
"argv": [
162-
"/Users/<your username>/go/bin/gophernotes",
163-
"{connection_file}"
164-
],
165-
"display_name": "Go",
166-
"language": "go",
167-
"name": "go"
168-
}
169-
```
53+
### OS X/macOS
17054

171-
### Local, Windows
55+
### Windows
17256

173-
Make sure you have the following dependencies:
57+
Make sure you have the MinGW toolchain:
17458

175-
- [Go](https://golang.org/) 1.5+ with cgo enabled
176-
- MinGW toolchain, such as:
17759
- [MinGW-w64](https://sourceforge.net/projects/mingw-w64/), for 32 and 64 bit Windows
17860
- [MinGW Distro](https://nuwen.net/mingw.html), for 64 bit Windows only
179-
- Jupyter (see [here](http://jupyter.readthedocs.org/en/latest/install.html) for more details on installing jupyter)
180-
- [ZeroMQ](http://zeromq.org/) (2.2.X or 4.x); for convenience, pre-built binaries (v4.2.1) are included in the zmq-win directory
18161

182-
Then:
183-
184-
1. Install goimports, if not already installed:
185-
186-
```
187-
go get golang.org/x/tools/cmd/goimports
188-
```
62+
Then:
18963

190-
2. Build and install gophernotes (using the pre-built binaries and `zmq-win\build.bat`):
64+
1. build and install gophernotes (using the pre-built binaries and `zmq-win\build.bat`):
19165

19266
```
19367
REM Download w/o building.
194-
go get -d github.com/gopherds/gophernotes
195-
cd %GOPATH%\src\github.com\gopherds\gophernotes\zmq-win
68+
go get -d github.com/gopherdata/gophernotes
69+
cd %GOPATH%\src\github.com\gopherdata\gophernotes\zmq-win
19670
19771
REM Build x64 version.
19872
build.bat amd64
@@ -209,7 +83,7 @@ Then:
20983
21084
```
21185
mkdir %APPDATA%\jupyter\kernels\gophernotes
212-
xcopy %GOPATH%\src\github.com\gopherds\gophernotes\kernel %APPDATA%\jupyter\kernels\gophernotes /s
86+
xcopy %GOPATH%\src\github.com\gopherdata\gophernotes\kernel %APPDATA%\jupyter\kernels\gophernotes /s
21387
```
21488
21589
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:
@@ -232,27 +106,60 @@ Then:
232106
}
233107
```
234108
109+
### Docker
110+
111+
You 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:
112+
113+
```
114+
$ docker run -it -p 8888:8888 gopherdata/gophernotes
115+
```
116+
117+
Or to run a Go notebook with access to common Go data science packages (gonum, gota, golearn, etc.), run:
118+
119+
```
120+
$ docker run -it -p 8888:8888 gopherdata/gophernotes-ds
121+
```
122+
123+
In either case, running this command should output a link that you can follow to access Jupyter in a browser.
235124
236125
## Getting Started
237126
238-
- If you completed one of the local installs above (i.e., not the Docker install), start the jupyter notebook:
127+
### Jupyter
128+
129+
- If you completed one of the local installs above (i.e., not the Docker install), start the jupyter notebook server:
239130
240131
```
241132
jupyter notebook
242133
```
243134
244-
- If you have a docker install, point a browser at `http://localhost:8888/`.
135+
- Select `Go` from the `New` drop down menu.
136+
137+
- Have fun!
138+
139+
### nteract
140+
141+
- Launch nteract.
245142
246-
- Select `Golang` from the `New` drop down menu.
143+
- From the nteract menu select Language -> Go.
247144
248-
- Have Fun!
145+
- Have fun!
249146
147+
## Limitations
148+
149+
gophernotes 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 limitation, which are discussed in further detail [here](https://github.com/cosmos72/gomacro#current-status). Most noteably, gophernotes does NOT support:
150+
151+
- unexported struct fields
152+
- interfaces - They can be declared, but nothing more: there is no way to implement them or call their methods
153+
- extracting methods from types - For example time.Duration.String should return a func(time.Duration) string but currently gives an error. Instead extracting methods from objects is supported: time.Duration(1s).String correctly returns a func() string
154+
- goto
155+
- named return values
156+
- named imports
250157
251158
## Troubleshooting
252159
253160
### gophernotes not found
254-
- Depending 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.
255161
162+
Depending 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.
256163
257164
### "Kernel error" in a running notebook
258165
@@ -277,20 +184,3 @@ sudo ln -s $HOME/go/bin/gophernotes /go/bin/gophernotes
277184
```
278185
279186
Restart jupyter, and you should now be up and running.
280-
281-
282-
## Custom Commands
283-
Some of the custom commands from the [gore](https://github.com/motemen/gore) REPL have carried over to `gophernotes`. Note, in particular, the syntax for importing packages:
284-
285-
```
286-
:print Show current source (currently prints to the terminal where the notebook server is running)
287-
:write [<filename>] Write out current source to file
288-
:help List commands
289-
:containerize Build a Docker image that executes the compiled Go code (must have Docker installed)
290-
```
291-
292-
## Licenses
293-
294-
`gophernotes` was created by [Daniel Whitenack](http://www.datadan.io/), and is licensed under an [MIT-style License](LICENSE.md).
295-
296-
The Golang Gopher image adapted for the gophernotes logo was created by [Takuya Ueda](http://u.hinoichi.net) and is licensed under the Creative Commons 3.0 Attributions license.

examples/Elman_srnn.png

-91.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)