[jupyter] Re: Register external IPython kernel with jupyter notebook?

2018-02-13 Thread Roland Weber
Hi Edward,

I'm not going to read up on everything you posted here :-)

I know the PID of the running kernel process. If I could somehow do a 
> subprocess.Popen() on that existing process and return a reference to that, 
> I think that would work.
>

Try starting a subprocess that joins or polls on the running kernel. You 
might also have to forward interrupts, unless you can overwrite the methods 
for interrupting and terminating the kernel process. The pipes are only 
used to check if the kernel process is still running, afaik.

Good luck,
  Roland

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/d0c4bd1c-3874-416d-9a80-548519ed9bbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [jupyter] How to know which config file is being used?

2018-02-13 Thread M Pacer
Nate, out of curiosity, does your configuration issue get caught if you use
jupyter_conf_search  to
search through your config files for the relevant option? It exists
specifically to help figure out questions like yours.

If it doesn't help with your original problem, please file an issue on that
repo. jupyter_conf_search should (ideally) cover .js configuration files as
well as traitlet-based .json/.py config files, but I'm not sure if it does
that currently.

Aside: I also use Vimium, and I have to have it disabled for all sites
originating from localhost.

On Mon, Feb 12, 2018 at 2:42 PM, Nate L.  wrote:

> It ended up being a chrome extension called Vimium, which seems to
> overwrite shortcuts for a lot of sites.
>
>
> On Monday, February 12, 2018 at 2:58:47 PM UTC-5, Nate L. wrote:
>>
>> You are so right.  I tried using this with Safari and everything works as
>> expected. I'll look into what extension in Chrome is getting in the way and
>> report back if I find out what it is.
>>
>> Thanks, Takowl!
>>
>>
>> On Monday, February 12, 2018 at 2:24:55 PM UTC-5, takowl wrote:
>>>
>>> Sorry, I've never seen it before. If you don't know you've installed an
>>> extension, chances are it's something built into your browser.
>>>
>>> On 12 February 2018 at 17:28, Nate L.  wrote:
>>>
 I don't think the search bar is something from a browser extension, (I
 don't think I ever added it), but if it is, I'd love to remove it so I can
 get back to good ol' Jupyter shortcuts :'(

 Would you know how to inspect whether it's an extension or not, and how
 I can remove it?

 Thanks, Takowl!!!

 Best,
 Nathan


 On Monday, February 12, 2018 at 11:39:32 AM UTC-5, takowl wrote:
>
> Reinstalling probably won't make a difference to issues in the browser
> like that, though it's always possible.
>
> Is the search bar something from a browser extension? If it captures
> the key event before we get it, there's not much we can do about that.
>
> On 12 February 2018 at 16:33, Nate L.  wrote:
>
>> Hi Takowl,
>>
>> Yea, I'm in the *notebook* command mode. Upon uninstalling the Vim
>> extension, I can now add cells with 'a', but that's about it. When I 
>> press
>> 'b', I get the search bar pop-up:
>>
>>
>> 
>>
>>
>> Not sure what's wrong. Maybe I should reinstall jupyter?  The problem
>> with reinstallation is that there are so many ways to uninstall it that I
>> don't know which would be optimal for my case.
>>
>>
>> On Monday, February 12, 2018 at 9:40:31 AM UTC-5, takowl wrote:
>>>
>>> Are you getting into *notebook* command mode? I don't use the vim
>>> extension myself, but from what I've heard, you press esc once to go 
>>> from
>>> edit mode to vim command mode, and then again to go to notebook command
>>> mode. The cell selection cursor on the left should turn from green to 
>>> blue
>>> when you switch to notebook command mode.
>>>
>>> On 12 February 2018 at 14:37, Nate L.  wrote:
>>>
 Hi all,

 Thanks for the responses! Yes, I meant that the actions are not
 shown in jupyter.

 Ok so now I've gotten it to the point where the vim commands are
 working (the custom.css file is changing the colors of my prompt), but 
 now
 the Jupyter commands are not working, so when I type DD or 'a' or 'b', 
 it's
 not deleting or adding any extra cells.

 I've read that the problem is the vim extension, but the vim
 extension is so good I don't really want to do without it.

 Any thoughts as to why it's happening?

 This is in my custom.js:


 1 // Configure CodeMirror Keymap
   2 require([
   3   'nbextensions/vim_binding/vim_binding',   // depends your
 installation
   4 ], function() {
   5   // Map jj to 
   6   CodeMirror.Vim.map("jk", "", "insert");
   7   // Swap j/k and gj/gk (Note that  mappings)
   8   CodeMirror.Vim.map("j", "(vim-binding-gj)", "normal");
   9   CodeMirror.Vim.map("k", "(vim-binding-gk)", "normal");
  10   CodeMirror.Vim.map("gj", "(vim-binding-j)", "normal");
  11   CodeMirror.Vim.map("gk", "(vim-binding-k)", "normal");
  12 });
  13
  14 // Configure Jupyter Keymap
  15 require([
  16   'nbextensions/vim_binding/vim_binding',
  17   'base/js/namespace',
  18 ], function(vim_binding, ns) {
  19   // Add post 

[jupyter] Re: Register external IPython kernel with jupyter notebook?

2018-02-13 Thread Edward Banner
Looking through the code a bit more I found this code snippet in 
jupyter_client/manager.py 

:

def _launch_kernel(self, kernel_cmd, **kw):
"""actually launch the kernel

override in a subclass to launch kernel subprocesses differently
"""
return launch_kernel(kernel_cmd, **kw)

I know the PID of the running kernel process. If I could somehow do a 
subprocess.Popen() on that existing process and return a reference to that, 
I think that would work.

Unfortunately I can't anything related to doing a subprocess.Popen() on an 
*existing* process...

On Tuesday, February 13, 2018 at 1:50:04 PM UTC-8, Edward Banner wrote:
>
> *Arg! I can't seem to get formatting down on google forums. I apologize. 
> Here is my response in full.*
>
> Hi Roland,
>
> Thanks for your response. Your suggestion makes sense. But does that mean 
> going with a custom server extension 
>  is 
> the way to go?
>
> I spent yesterday attempting to accomplish this solely though jupyter 
> configuration options. For a running kernel with information
>
> {
>   "shell_port": 63391,
>   "iopub_port": 63394,
>   "stdin_port": 63392,
>   "control_port": 63393,
>   "hb_port": 63396,
>   "ip": "127.0.0.1",
>   "key": "fff108f8-b1bf9b17aa337ce7d3d14565",
>   "transport": "tcp",
>   "signature_scheme": "hmac-sha256",
>   "kernel_name": ""
> }
>
> I set the following variables in jupyter_notebook_config.py.
>
> c.ConnectionFileMixin.connection_file = 
> '/Users/ebanner/Library/Jupyter/runtime/kernel-10962.json'
> c.ConnectionFileMixin.control_port = 63393
> c.ConnectionFileMixin.iopub_port = 63394
> c.ConnectionFileMixin.stdin_port = 63392
> c.ConnectionFileMixin.hb_port = 63396
> c.ConnectionFileMixin.ip = '127.0.0.1'
> c.ConnectionFileMixin.shell_port = 63391
> c.ConnectionFileMixin.transport = 'tcp'
>
> However when I created a new notebook I get errors like
>
> [I 12:53:44.981 NotebookApp] KernelRestarter: restarting kernel (1/5)
> [D 12:53:44.982 NotebookApp] Starting kernel: [
> '/Users/ebanner/.anaconda/envs/py36/bin/python', '-m', 
> 'ipykernel_launcher', '-f', 
> '/Users/ebanner/Library/Jupyter/runtime/kernel-f746726f-0d27-4d63-b520-2f1c84bf5196.json'
> ]
> [D 12:53:44.986 NotebookApp] Connecting to: tcp://127.0.0.1:63393
> Traceback (most recent call last):
>   File "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/runpy.py", line 
> 193, in _run_module_as_main
> "__main__", mod_spec)
>   File "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/runpy.py", line 
> 85, in _run_code
> exec(code, run_globals)
>   File 
> "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/ipykernel_launcher.py"
> , line 16, in 
> app.launch_new_instance()
>   File 
> "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/traitlets/config/application.py"
> , line 657, in launch_instance
> app.initialize(argv)
>   File "", line 2, in initialize
>   File 
> "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/traitlets/config/application.py"
> , line 87, in catch_config_error
> return method(app, *args, **kwargs)
>   File 
> "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/ipykernel/kernelapp.py"
> , line 448, in initialize
> self.init_sockets()
>   File 
> "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/ipykernel/kernelapp.py"
> , line 238, in init_sockets
> self.shell_port = self._bind_socket(self.shell_socket, self.shell_port
> )
>   File 
> "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/ipykernel/kernelapp.py"
> , line 180, in _bind_socket
> s.bind("tcp://%s:%i" % (self.ip, port))
>   File "zmq/backend/cython/socket.pyx", line 495, in zmq.backend.cython.
> socket.Socket.bind (zmq/backend/cython/socket.c:5653)
>   File "zmq/backend/cython/checkrc.pxd", line 25, in zmq.backend.cython.
> checkrc._check_rc (zmq/backend/cython/socket.c:10014)
> zmq.error.ZMQError: Address already in use
>
> until it hits the maximum number of retries. Presumably this is because 
> the ipykernel command attempts to create a *new* socket but since it 
> already exists it fails to do so.
>
> Thinking that I could "trick" jupyter into not using ipykernel and just 
> use the existing sockets I set
>
> c.KernelManager.kernel_cmd = [
> '/Users/ebanner/.anaconda/envs/py36/bin/python', '/Users/ebanner/bar.py']
>
> where bar.py contains
>
> while True:
> pass
>
> After creating another new notebook I get
>
> [D 12:59:37.283 NotebookApp] Opening websocket /api/kernels/9a6c1e7d-12c4-
> 4d98-a0c6-1f227627f784/channels
> [D 12:59:37.283 NotebookApp] Connecting to: tcp://127.0.0.1:63391
> [D 12:59:37.284 NotebookApp] Connecting to: tcp://127.0.0.1:63394
> [D 12:59:37.284 NotebookApp] Connecting to: tcp://127.0.0.1:63392
>
> which gave me hope! But then when I tried to execute a cell it just hangs. 
> I 

[jupyter] Re: Register external IPython kernel with jupyter notebook?

2018-02-13 Thread Edward Banner
*Arg! I can't seem to get formatting down on google forums. I apologize. 
Here is my response in full.*

Hi Roland,

Thanks for your response. Your suggestion makes sense. But does that mean 
going with a custom server extension 
 is 
the way to go?

I spent yesterday attempting to accomplish this solely though jupyter 
configuration options. For a running kernel with information

{
  "shell_port": 63391,
  "iopub_port": 63394,
  "stdin_port": 63392,
  "control_port": 63393,
  "hb_port": 63396,
  "ip": "127.0.0.1",
  "key": "fff108f8-b1bf9b17aa337ce7d3d14565",
  "transport": "tcp",
  "signature_scheme": "hmac-sha256",
  "kernel_name": ""
}

I set the following variables in jupyter_notebook_config.py.

c.ConnectionFileMixin.connection_file = 
'/Users/ebanner/Library/Jupyter/runtime/kernel-10962.json'
c.ConnectionFileMixin.control_port = 63393
c.ConnectionFileMixin.iopub_port = 63394
c.ConnectionFileMixin.stdin_port = 63392
c.ConnectionFileMixin.hb_port = 63396
c.ConnectionFileMixin.ip = '127.0.0.1'
c.ConnectionFileMixin.shell_port = 63391
c.ConnectionFileMixin.transport = 'tcp'

However when I created a new notebook I get errors like

[I 12:53:44.981 NotebookApp] KernelRestarter: restarting kernel (1/5)
[D 12:53:44.982 NotebookApp] Starting kernel: [
'/Users/ebanner/.anaconda/envs/py36/bin/python', '-m', 'ipykernel_launcher',
 '-f', 
'/Users/ebanner/Library/Jupyter/runtime/kernel-f746726f-0d27-4d63-b520-2f1c84bf5196.json'
]
[D 12:53:44.986 NotebookApp] Connecting to: tcp://127.0.0.1:63393
Traceback (most recent call last):
  File "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/runpy.py", line 193
, in _run_module_as_main
"__main__", mod_spec)
  File "/Users/ebanner/.anaconda/envs/py36/lib/python3.6/runpy.py", line 85,
 in _run_code
exec(code, run_globals)
  File 
"/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/ipykernel_launcher.py"
, line 16, in 
app.launch_new_instance()
  File 
"/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/traitlets/config/application.py"
, line 657, in launch_instance
app.initialize(argv)
  File "", line 2, in initialize
  File 
"/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/traitlets/config/application.py"
, line 87, in catch_config_error
return method(app, *args, **kwargs)
  File 
"/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/ipykernel/kernelapp.py"
, line 448, in initialize
self.init_sockets()
  File 
"/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/ipykernel/kernelapp.py"
, line 238, in init_sockets
self.shell_port = self._bind_socket(self.shell_socket, self.shell_port)
  File 
"/Users/ebanner/.anaconda/envs/py36/lib/python3.6/site-packages/ipykernel/kernelapp.py"
, line 180, in _bind_socket
s.bind("tcp://%s:%i" % (self.ip, port))
  File "zmq/backend/cython/socket.pyx", line 495, in zmq.backend.cython.
socket.Socket.bind (zmq/backend/cython/socket.c:5653)
  File "zmq/backend/cython/checkrc.pxd", line 25, in zmq.backend.cython.
checkrc._check_rc (zmq/backend/cython/socket.c:10014)
zmq.error.ZMQError: Address already in use

until it hits the maximum number of retries. Presumably this is because the 
ipykernel command attempts to create a *new* socket but since it already 
exists it fails to do so.

Thinking that I could "trick" jupyter into not using ipykernel and just use 
the existing sockets I set

c.KernelManager.kernel_cmd = [
'/Users/ebanner/.anaconda/envs/py36/bin/python', '/Users/ebanner/bar.py']

where bar.py contains

while True:
pass

After creating another new notebook I get

[D 12:59:37.283 NotebookApp] Opening websocket /api/kernels/9a6c1e7d-12c4-
4d98-a0c6-1f227627f784/channels
[D 12:59:37.283 NotebookApp] Connecting to: tcp://127.0.0.1:63391
[D 12:59:37.284 NotebookApp] Connecting to: tcp://127.0.0.1:63394
[D 12:59:37.284 NotebookApp] Connecting to: tcp://127.0.0.1:63392

which gave me hope! But then when I tried to execute a cell it just hangs. 
I did notice that http://localhost:/api/kernels has the following 
information.

[
{
id: "9b260abf-072f-48e2-b5f0-213d934418a2",
name: "python3",
last_activity: "2018-02-13T21:10:41.460182Z",
execution_state: "starting",
connections: 0
}
]

However the execution_state being stuck at "starting" and connections being 
at 0 make me think that bar.py isn't quite doing enough.

Digging into the code a bit I found the object returned from the call to 
ipykernel is a subprocess.Popen() object. But I couldn't find anywhere else 
in the code except KernelManager.is_alive() where Popen.poll() is called on 
it 

.

I also tried creating a custom kernel manager class and set

c.NotebookApp.kernel_manager_class = 
'kernelmanager.ExistingMappingKernelManager'


Re: [jupyter] An example of what can be built with the JupyterLab ecosystem

2018-02-13 Thread Fernando Perez
On Mon, Feb 12, 2018 at 11:49 PM, Simon Biggs 
wrote:

> Hi Fernando,
>
> Thank you for the encouragement. Really chuffed that you want to include
> what I have done as an example in the talk you are giving. Puts a huge
> smile on my face. My supervisor was also quite impressed.
>

Works perfectly, got it running yesterday without any problems, thanks!

Lovely work, thanks for sharing.

Best

f

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CAHAreOof1dxhTnoFNUpTWWoG_inCPgbCizasNFjQ2aiY_S%2B%2BqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[jupyter] Re: Jupyter startup

2018-02-13 Thread David Doherty
Got any example error details? I've gone through this a couple times as I'm 
in a corporate firewall but I'm not exactly sure what the issue is.

I would recommend following Lawrence's approach if you're not

On Sunday, 14 January 2018 23:53:33 UTC-5, Vince Yu wrote:
>
> Hi everyone,
>
> I would like to ask this community. Where I can execute the Jupyter 
> Notebook locally without undergoing installation due to restricted 
> rights(pip and anaconda).
>
> So far, I have tested by installing other packages numpy, matplotlib, and 
> others to PC A. Then copy pasting the extracted folders and files into PC 
> B. But with jupyter, to execute it via cmd i am missing something; 
> eventhough I did the same process as the other packages.
>
> So I would like to understand where and what does the shortcut(cmd: 
> jupyter notebook) do.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/97e7030f-c974-4f8b-8023-c6ed933a50df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.