Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with jupyter_client>=6 #151

Open
vpipkt opened this issue Feb 24, 2020 · 9 comments
Open

Not compatible with jupyter_client>=6 #151

vpipkt opened this issue Feb 24, 2020 · 9 comments

Comments

@vpipkt
Copy link

vpipkt commented Feb 24, 2020

It appears that the recent release of jupyter_client 6.0.0 introduces a breaking change

https://pypi.org/project/jupyter-client/#history

Environment Mac OS X, python 3.7.6

Also seen in linux environment on CI

$ pweave docs/reproject.pymd 
Traceback (most recent call last):
  File "/Users/jbrown/src/earthai/.virtualenv_p37/bin/pweave", line 8, in <module>
    sys.exit(weave())
  File "/Users/jbrown/src/earthai/.virtualenv_p37/lib/python3.7/site-packages/pweave/scripts.py", line 53, in weave
    pweave.weave(infile, **opts_dict)
  File "/Users/jbrown/src/earthai/.virtualenv_p37/lib/python3.7/site-packages/pweave/__init__.py", line 59, in weave
    doc.weave()
  File "/Users/jbrown/src/earthai/.virtualenv_p37/lib/python3.7/site-packages/pweave/pweb.py", line 192, in weave
    self.run()
  File "/Users/jbrown/src/earthai/.virtualenv_p37/lib/python3.7/site-packages/pweave/pweb.py", line 127, in run
    self.wd
  File "/Users/jbrown/src/earthai/.virtualenv_p37/lib/python3.7/site-packages/pweave/processors/jupyter.py", line 169, in __init__
    super(IPythonProcessor, self).__init__(*args, embed_kernel=embed)
  File "/Users/jbrown/src/earthai/.virtualenv_p37/lib/python3.7/site-packages/pweave/processors/jupyter.py", line 36, in __init__
    kc.start_channels()
  File "/Users/jbrown/src/earthai/.virtualenv_p37/lib/python3.7/site-packages/ipykernel/inprocess/client.py", line 64, in start_channels
    super(InProcessKernelClient, self).start_channels()
  File "/Users/jbrown/src/earthai/.virtualenv_p37/lib/python3.7/site-packages/jupyter_client/client.py", line 118, in start_channels
    self.control_channel.start()
  File "/Users/jbrown/src/earthai/.virtualenv_p37/lib/python3.7/site-packages/jupyter_client/client.py", line 200, in control_channel
    socket, self.session, self.ioloop
TypeError: ChannelABC() takes no arguments

@lgarcin
Copy link

lgarcin commented Mar 1, 2020

Same error here ChannelABC() takes no arguments with

  • Windows 10
  • python 3.7.5
  • jupyter-client 6.0.0

No problem with jupyter-client 5.3.4

@JamesOwers
Copy link

Same. I think the way kernels are instantiated must have changed. Here's the issue's exit point from pweave:

kc = km.client()
.

My guess is a difference in the jupyter_client.KernelManager.
https://github.com/jupyter/jupyter_client/blob/fa0c78b97bc7183e1a6c0fa2f88fee943e52580e/jupyter_client/manager.py#L32

Looking at the diffs to jupyter_client.manager I'm a bit stumped - https://github.com/jupyter/jupyter_client/compare/0f13a70c920123237c804c68a7bb2f469da2ad0c..9f7c213

@JamesOwers
Copy link

What I can say is that if you specify a kernel directly, it works. But you cannot do this from command line for pypublish 😢

@thirschbuechler
Copy link

A temporary fix seems to be to downgrade

Native Python / Linux:

sudo apt install python3-pip python3-setuptools
python3 -m pip install --upgrade jupyter_client==5.3.1

Anaconda, probably something like this (haven't tried):

conda install notebook==5.3.1
conda install jupyter_client==5.3.1

Apparently not the first time this happend for Jupyter:
jupyter/notebook#4937

@vpipkt
Copy link
Author

vpipkt commented Mar 8, 2020 via email

@vpipkt vpipkt changed the title Not compatible with jupyter_client>6 Not compatible with jupyter_client>=6 Mar 9, 2020
vpipkt added a commit to vpipkt/Pweave that referenced this issue Mar 9, 2020
@lgarcin
Copy link

lgarcin commented Mar 23, 2020

Everything seems to go back to normal with the release of jupyter-client 6.1.0.

Environment : Windows10, python 3.7.5, jupyter-client 6.1.0

@vpipkt
Copy link
Author

vpipkt commented Mar 24, 2020

Interesting. I will try to test locally ... But the CI job looks like it may have some other issues basically in need of a lot of maintenance since the last release.

@vpipkt
Copy link
Author

vpipkt commented Mar 24, 2020

I am still seeing the error on Mac OSX, python 3.7.6, jupyter-client 6.1.0

@lgarcin
Copy link

lgarcin commented Apr 2, 2020

I upgraded from Python 3.7.5 to Python 3.8.2 and now I see a new error.

c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\pweave\__init__.py:51: SyntaxWarning: "is not" w
ith a literal. Did you mean "!="?
  assert file != "" is not None, "No input specified"
Traceback (most recent call last):
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 528, in ge
t
    value = obj._trait_values[self.name]
KeyError: 'iopub_socket'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 528, in ge
t
    value = obj._trait_values[self.name]
KeyError: 'iopub_thread'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\laure\appdata\local\programs\python\python38\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\laure\appdata\local\programs\python\python38\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\laure\AppData\Local\Programs\Python\Python38\Scripts\pweave.exe\__main__.py", line 7, in <module>
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\pweave\scripts.py", line 53, in weave
    pweave.weave(infile, **opts_dict)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\pweave\__init__.py", line 63, in weave
    doc.weave()
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\pweave\pweb.py", line 192, in weave
    self.run()
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\pweave\pweb.py", line 122, in run
    proc = Processor(copy.deepcopy(self.parsed),
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\pweave\processors\jupyter.py", line 169,
 in __init__
    super(IPythonProcessor, self).__init__(*args, embed_kernel=embed)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\pweave\processors\jupyter.py", line 34,
in __init__
    km.start_kernel(cwd=path, stderr=open(os.devnull, 'w'))
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\ipykernel\inprocess\manager.py", line 46
, in start_kernel
    self.kernel = InProcessKernel(parent=self, session=self.session)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\ipykernel\inprocess\ipkernel.py", line 7
2, in __init__
    super(InProcessKernel, self).__init__(**traits)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\ipykernel\ipkernel.py", line 71, in __in
it__
    self.shell.displayhook.pub_socket = self.iopub_socket
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 556, in __
get__
    return self.get(obj, cls)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 535, in ge
t
    value = self._validate(obj, dynamic_default())
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\ipykernel\inprocess\ipkernel.py", line 6
7, in _default_iopub_socket
    return self.iopub_thread.background_socket
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 556, in __
get__
    return self.get(obj, cls)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 535, in ge
t
    value = self._validate(obj, dynamic_default())
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\ipykernel\inprocess\ipkernel.py", line 5
9, in _default_iopub_thread
    thread = IOPubThread(self._underlying_iopub_socket)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\ipykernel\iostream.py", line 71, in __in
it__
    self._setup_event_pipe()
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\ipykernel\iostream.py", line 90, in _set
up_event_pipe
    self._event_puller = ZMQStream(pipe_in, self.io_loop)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\zmq\eventloop\zmqstream.py", line 127, i
n __init__
    self._init_io_state()
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\zmq\eventloop\zmqstream.py", line 546, i
n _init_io_state
    self.io_loop.add_handler(self.socket, self._handle_events, self.io_loop.READ)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\site-packages\tornado\platform\asyncio.py", line 100,
in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "c:\users\laure\appdata\local\programs\python\python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

I applied the fix described here.
jupyter/notebook#4613 (comment)

I copied these lines at the beginning of __init__.py in the pweave package.

import asyncio, sys

if sys.platform == 'win32':
  asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

Everything now works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants