question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exporting a python file as a notebook does not use the kernel matching the current python

See original GitHub issue

Bug: Notebook Editor, Interactive Window, Editor cells

Steps to cause the bug to occur

  1. I am following the instruction to export my python file into a jupyter notebook.
  2. Export succeeded and I can run the file in VSCode. image
  3. However, when I open the notebook from browser, it will show Kernel error. Restarting & Disconnecting the kernel will not help. image

Here is the detailed error:

Traceback (most recent call last):
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\tornado\web.py", line 1699, in _execute
    result = await result
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
    type=mtype))
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\users\XXX\appdata\local\programs\python\python37\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:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel
    **kw)
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages\jupyter_client\launcher.py", line 138, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "c:\users\XXX\appdata\local\programs\python\python37\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

Actual behavior

Jupyter Notebook exported from VSCode is showing kernel error after opening in browser.

Expected behavior

It should look like normal jupyter notebook and no kernel error.

Your Jupyter and/or Python environment

Please provide as much info as you readily know

  • Jupyter server running: Local
  • Extension version: 2020.1.57204 image
  • VS Code version: 1.41 image
  • Setting python.jediEnabled: false image
  • Python version: 3.7.6
  • OS: Windows 10
  • Virtual environment: N/A

Developer Tools Console Output

Microsoft Data Science for VS Code Engineering Team: @rchiodo, @IanMatthewHuff, @DavidKutu, @DonJayamanne, @greazer

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
mukerongcommented, Jan 9, 2020

Thank you!

1reaction
mukerongcommented, Jan 8, 2020

@rchiodo

You might be right. I just noticed there are two available kernel. It was just one available before.

image

Python 3 is the one that has issue. Python 3.7 works fine.

However, based on the metadata, the kernel is using python 3.7. I don’t have any issues running the same notebook in VSCode jupyter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exporting a python file as a notebook does not use the kernel ...
I am following the instruction to export my python file into a jupyter notebook. Export succeeded and I can run the file in...
Read more >
Cannot open jupyter notebook in VSCode - Stack Overflow
Press Ctrl + Shift + P ; Type: Export Current Python File as Jupyter Notebook. Share.
Read more >
Link your Virtual Environment to Jupyter Using Kernels
Let the prompt run and install ipykernel . We can now create Python kernels for Jupyter. Using Virtual Environments in Jupyter as Kernels....
Read more >
Using at the Command Line - Jupytext documentation
Representing Jupyter notebooks as scripts requires a solid round trip conversion. You don't want your notebooks (nor your scripts) to be modified because...
Read more >
Working with Jupyter Notebooks in Visual Studio Code
Next, select a kernel using the kernel picker in the top right. ... You can export a Jupyter Notebook as a Python file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found