You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jupyter Kernel Client to connect via WebSocket to Jupyter Servers.
9
+
[](https://github.com/sponsors/datalayer)
13
10
14
-
## Requirements
11
+
#Jupyter Kernel Client (via WebSocket and HTTP)
15
12
16
-
- Jupyter Server with ipykernel running somewhere.
Jupyter Kernel Client allows you to connect via WebSocket and HTTP to Jupyter Kernels. It also provide a easy to use interactive Konsole (console for **K**ernels).
24
17
25
-
To install the extension, execute:
18
+
To install the library, run the following command.
26
19
27
20
```bash
28
21
pip install jupyter_kernel_client
29
22
```
30
23
31
24
## Usage
32
25
33
-
### Kernel Client
34
-
35
-
1. Start a Jupyter Server (or JupyterLab or Jupyter Notebook)
26
+
Check you have a Jupyter Server with ipykernel running somewhere. You can install those packages using:
36
27
37
28
```sh
38
-
jupyter server
39
-
# ...
40
-
# To access the server, open this file in a browser:
2. Note down the URL (usually `http://localhost:8888`) and the Server Token (in the above example it will be `aed1fef59f754b9bfc99017e1dcf4d5602fc1a97d331069b`)
32
+
### Kernel Client
33
+
34
+
2. Start a Jupyter Server.
48
35
49
-
3. Launch `python` in a terminal.
36
+
```sh
37
+
jupyter server --port 8888 --IdentityProvider.token MY_TOKEN
38
+
```
50
39
51
-
4. Execute the following snippet
40
+
3. Launch `python` in a terminal and execute the following snippet (update the server_url and token).
52
41
53
42
```py
54
43
import os
@@ -57,7 +46,7 @@ from platform import node
57
46
from jupyter_kernel_client import KernelClient
58
47
59
48
60
-
with KernelClient(server_url="http://localhost:8888", token="aed1fef59f754b9bfc99017e1dcf4d5602fc1a97d331069b") as kernel:
49
+
with KernelClient(server_url="http://localhost:8888", token="MY_TOKEN") as kernel:
61
50
reply = kernel.execute(
62
51
"""import os
63
52
from platform import node
@@ -75,40 +64,26 @@ print(f"Hey {os.environ.get('USER', 'John Smith')} from {node()}.")
75
64
assert reply["status"] =="ok"
76
65
```
77
66
78
-
### Jupyter Console
67
+
### Jupyter Konsole (aka Console for Kernels)
79
68
80
-
This package can be used to open a Jupyter Console to a Jupyter Kernel through HTTP 🐣.
69
+
This package can be used to open a Jupyter Console to a Jupyter Kernel 🐣.
81
70
82
71
1. Install the optional dependencies.
83
72
84
73
```sh
85
74
pip install jupyter-kernel-client[konsole]
86
75
```
87
76
88
-
2. Start a Jupyter Server (or JupyterLab or Jupyter Notebook).
89
-
90
-
```sh
91
-
jupyter server
92
-
# ...
93
-
# To access the server, open this file in a browser:
3. Note down the URL (usually `http://localhost:8888`) and the Server Token (in the above example it will be `aed1fef59f754b9bfc99017e1dcf4d5602fc1a97d331069b`)
0 commit comments