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

[Python 3.8][Windows 10] Kernel error after opening notebook file (Tornado manually patched to return to selector event loop) #5040

Closed
indeets-vasily opened this issue Nov 8, 2019 · 2 comments

Comments

@indeets-vasily
Copy link

I have Python 3.8.0 on windows 10 x86-64.

At first Jupyter console was throwin NotImplementedError. After searching web I applied patches suggested there:
https://stackoverflow.com/questions/58422817/jupyter-notebook-with-python-3-8-notimplementederror
https://stackoverflow.com/questions/54805213/jupyter-notebook-cannot-start-with-python-3-8-in-windows-10

Basically, I added following strings to /tornado/platform/asyncio.py:

import sys

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

After applying this change I don't get NotImplementedError and I see list of files/directories on my computer in the web browser. But when I open notebook file I see Kernel Error and have following output in the console:

[E 22:27:23.239 NotebookApp] Uncaught exception POST /api/sessions (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "c:\python\python38\lib\site-packages\tornado\web.py", line 1699, in _execute
        result = await result
      File "c:\python\python38\lib\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "c:\python\python38\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
        model = yield maybe_future(
      File "c:\python\python38\lib\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "c:\python\python38\lib\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "c:\python\python38\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
        kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
      File "c:\python\python38\lib\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "c:\python\python38\lib\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "c:\python\python38\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 100, in start_kernel_for_session
        kernel_id = yield maybe_future(
      File "c:\python\python38\lib\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "c:\python\python38\lib\site-packages\tornado\gen.py", line 209, in wrapper
        yielded = next(result)
      File "c:\python\python38\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
        super(MappingKernelManager, self).start_kernel(**kwargs)
      File "c:\python\python38\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
        km.start_kernel(**kwargs)
      File "c:\python\python38\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
        self.write_connection_file()
      File "c:\python\python38\lib\site-packages\jupyter_client\connect.py", line 470, in write_connection_file
        self.connection_file, cfg = write_connection_file(self.connection_file,
      File "c:\python\python38\lib\site-packages\jupyter_client\connect.py", line 141, in write_connection_file
        with secure_write(fname) as f:
      File "c:\python\python38\lib\contextlib.py", line 113, in __enter__
        return next(self.gen)
      File "c:\python\python38\lib\site-packages\jupyter_core\paths.py", line 424, in secure_write
        win32_restrict_file_to_user(fname)
      File "c:\python\python38\lib\site-packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
        import win32api
    ImportError: DLL load failed while importing win32api: The specified module could not be found.
[W 22:27:23.239 NotebookApp] Unhandled error
[E 22:27:23.239 NotebookApp] {
      "Host": "localhost:8888",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0",
      "Accept": "application/json, text/javascript, */*; q=0.01",
      "Accept-Language": "en-US,en;q=0.5",
      "Accept-Encoding": "gzip, deflate",
      "Content-Type": "application/json",
      "X-Xsrftoken": "2|5b5eff67|0db0eda37f66596ea26522cfad762e4c|1573142996",
      "X-Requested-With": "XMLHttpRequest",
      "Content-Length": "102",
      "Origin": "http://localhost:8888",
      "Connection": "keep-alive",
      "Referer": "http://localhost:8888/notebooks/watch%20shop/Untitled.ipynb",
      "Cookie": "username-localhost-8888=\"2|1:0|10:1573248432|23:username-localhost-8888|44:ZGU2ZTFiZWFkNzQzNDRiN2IwOWI4ZGIzYjAxY2Y0ZDM=|da23157c2eb09136be584ce85e512a75a8cb5d3b74b1037fc9f1b5698e81182b\"; _xsrf=2|5b5eff67|0db0eda37f66596ea26522cfad762e4c|1573142996"
    }
[E 22:27:23.239 NotebookApp] 500 POST /api/sessions (127.0.0.1) 62.49ms referer=http://localhost:8888/notebooks/watch%20shop/Untitled.ipynb
@afvca
Copy link

afvca commented Nov 9, 2019

See this #4980 (comment)

@indeets-vasily
Copy link
Author

It worked, thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants