KxSystems / pyq

PyQ — Python for kdb+
http://code.kx.com/q/interfaces
Apache License 2.0
191 stars 49 forks source link

Issues with kernel startup for ipyq in Jupyter Notebook #101

Closed eepgwde closed 5 years ago

eepgwde commented 5 years ago

Questions

Steps to reproduce the issue

~/q/l32/q python.q -mpyq.kernel install --user

This returns

jupyter kernelspec listAvailable kernels:
  pyq_3      /home/weaves/.local/share/jupyter/kernels/pyq_3
  python3    /misc/share/1/anaconda/envs/dash0/share/jupyter/kernels/python3

I used the -user option to get the kernel spec file

~/.local/share/jupyter/kernels/pyq_3/kernel.json

And that contains:

{
    "argv": [
        null,
        "pyq-kernel.p",
        "1024",
        "65535",
        "{connection_file}"
    ],
    "display_name": "PyQ 3",
    "language": "python"
}

Only when I changed the entries, would Jupyter make an attempt to start and

{
    "argv": [
        "/misc/share/1/anaconda/bin/ipyq",
        "/misc/share/1/anaconda/q/pyq-kernel.p",
        "1024",
        "65535",
        "{connection_file}"
    ],
    "display_name": "PyQ 3",
    "language": "python"
}

Expected result

I'm hoping for the ipyq Kernel to start up in the Jupyter notebook.

Actual result

Five attempts at this 0;IPython: dash0/plotly^GThe autoreload extension is already loaded. To reload it, use: %reload_ext autoreload And then

MultipleInstanceError                     Traceback (most recent call last)
/misc/share/1/anaconda/q/pyq-kernel.p in <module>
      1 from pyq.kernel import start
----> 2 start()

/misc/share/1/anaconda/envs/dash0/lib/python3.7/site-packages/pyq/kernel.py in start()
    114 def start():
    115     global app
--> 116     app = IPKernelApp.instance(kernel_class=Kernel)
    117     args = [str(a) for a in q('.z.x')]
    118     app.initialize(['-f', args[-1]])

/misc/share/1/anaconda/envs/dash0/lib/python3.7/site-packages/traitlets/config/configurable.py in instance(cls, *args, **kwargs)
    421             raise MultipleInstanceError(
    422                 'Multiple incompatible subclass instances of '
--> 423                 '%s are being created.' % cls.__name__
    424             )
    425 

[W 23:05:44.799 NotebookApp] KernelRestarter: restart failed

Workaround

If you know workaround, please provide it here.

sashkab commented 5 years ago

Why are you using ~/q/l32/q python.q instead of pyq command? I see you're not using virtual environment, and it seems that you use modified version of PyQ, as 4.1.4 does not support python 3.7.

eepgwde commented 5 years ago

pyq and ipyq do work for me with python 3.7. It's just the linkage with jupyter notebook that doesn't work.

There's no guidance on what the pyq_3/kernel.json file should contain.

You mentioned using pyq. I don't know what you were referring to. This command is the only one I mentioned, it fails with pyq.

~/q/l32/q python.q -mpyq.kernel install --user

You mentioned using a virtual environment. I stated that I use anaconda.

I found out that pyq can't get around the GIL, so the q component is only useful as a blocked client, so I'll have to run q as a separate process anyway.

sashkab commented 5 years ago

You mentioned using a virtual environment. I stated that I use anaconda.

Anaconda != virtual environment. Please follow guide on setting up PyQ in the virtual environment in order to troubleshoot the issue.

It's just the linkage with jupyter notebook that doesn't work.

It's a known issue — see #99 for workaround.

There's no guidance on what the pyq_3/kernel.json file should contain.

You shouldn't touch that file. You need to install Jupyter kernel using following commands:

pip install pyq-kernel
pyq -m pyq.kernel install

You mentioned using pyq. I don't know what you were referring to.

pyq is command for starting PyQ.