Vscode-jupyter: Bug in Export as Python script

Created on 10 Oct 2020  路  4Comments  路  Source: microsoft/vscode-jupyter

Bug: Notebook Editor, Interactive Window, Editor cells

Steps to cause the bug to occur

  1. Launch a new or existing notebook with code and markdown
  2. Click "Export as" and select Python Script

Actual behavior

The cell marker for markdown in the exported script file appears as

null.tpl [markdown]
# ## heading

Expected behavior

In version v2020.9.112786 the output python script appears as follows

# %% [markdown]
# ## heading

Your Jupyter and/or Python environment

_Please provide as much info as you readily know_

  • Jupyter server running: Local
  • Extension version: v2020.9.114305
  • VS Code version: 1.50.0
  • Setting python.jediEnabled: false
  • Setting python.languageServer: Microsoft
  • Python and/or Anaconda version: 3.7 and 3.8
  • OS: Mac
  • Virtual environment: conda

Python Output

> pyenv root
> python3.7 ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> ~/Applications/miniconda3/envs/hv5/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> ~/Applications/miniconda3/bin/conda info --json
Starting Microsoft Python language server.
> ~/Applications/miniconda3/bin/conda env list
Python interpreter path: ~/Applications/miniconda3/envs/hv5/bin/python
> ~/Applications/miniconda3/bin/conda env list
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import jupyter"
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import notebook"
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py jupyter kernelspec --version
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> ~/Applications/miniconda3/envs/hv5/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/Desktop/t -s --cache-clear
cwd: ~/Desktop/t
Error 2020-10-10 11:25:54: Failed to parse discovered Test [r [Error]: Traceback (most recent call last):
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py", line 17, in <module>
    from testing_tools.adapter.__main__ import parse_args, main
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/__main__.py", line 9, in <module>
    from . import pytest, report
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/__init__.py", line 7, in <module>
    from ._discovery import discover
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

    at ChildProcess.<anonymous> (/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/out/client/extension.js:9:53541)
    at Object.onceWrapper (events.js:313:26)
    at ChildProcess.emit (events.js:223:5)
    at ChildProcess.EventEmitter.emit (domain.js:475:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)]
> ~/Applications/miniconda3/bin/pytest --version
Error 2020-10-10 11:25:54: Python Extension: displayDiscoverStatus [r [Error]: Traceback (most recent call last):
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py", line 17, in <module>
    from testing_tools.adapter.__main__ import parse_args, main
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/__main__.py", line 9, in <module>
    from . import pytest, report
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/__init__.py", line 7, in <module>
    from ._discovery import discover
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

    at ChildProcess.<anonymous> (/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/out/client/extension.js:9:53541)
    at Object.onceWrapper (events.js:313:26)
    at ChildProcess.emit (events.js:223:5)
    at ChildProcess.EventEmitter.emit (domain.js:475:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)]
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import nbconvert"
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py jupyter nbconvert --version
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py jupyter nbconvert --version
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py jupyter nbconvert --version
> ~/Applications/miniconda3/envs/plot/bin/python (daemon) -m jupyter nbconvert /var/folders/lk/s__7f9fx15x_zrw6q5xkmm500000gp/T/079a338f-17a4-4099-bc8e-d7e892f4ed32/tmp-24986s97W0AoEEAEI.ipynb --to python --stdout --template /var/folders/lk/s__7f9fx15x_zrw6q5xkmm500000gp/T/tmp-24986TD26cET8TVOb.tpl
> ~/Applications/miniconda3/envs/hv5/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/Desktop/t -s
cwd: ~/Desktop/t
Error 2020-10-10 11:28:09: Failed to parse discovered Test [r [Error]: Traceback (most recent call last):
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py", line 17, in <module>
    from testing_tools.adapter.__main__ import parse_args, main
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/__main__.py", line 9, in <module>
    from . import pytest, report
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/__init__.py", line 7, in <module>
    from ._discovery import discover
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

    at ChildProcess.<anonymous> (/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/out/client/extension.js:9:53541)
    at Object.onceWrapper (events.js:313:26)
    at ChildProcess.emit (events.js:223:5)
    at ChildProcess.EventEmitter.emit (domain.js:475:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)]
> ~/Applications/miniconda3/envs/hv5/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/Desktop/t -s
cwd: ~/Desktop/t
Error 2020-10-10 11:28:12: Failed to parse discovered Test [r [Error]: Traceback (most recent call last):
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py", line 17, in <module>
    from testing_tools.adapter.__main__ import parse_args, main
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/__main__.py", line 9, in <module>
    from . import pytest, report
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/__init__.py", line 7, in <module>
    from ._discovery import discover
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

    at ChildProcess.<anonymous> (/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/out/client/extension.js:9:53541)
    at Object.onceWrapper (events.js:313:26)
    at ChildProcess.emit (events.js:223:5)
    at ChildProcess.EventEmitter.emit (domain.js:475:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)]
Starting Microsoft Python language server.
Python interpreter path: ~/Applications/miniconda3/envs/data/bin/python
> ~/Applications/miniconda3/bin/conda info --json
> ~/Applications/miniconda3/bin/conda info --json
> ~/Applications/miniconda3/envs/data/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/Desktop/t -s --cache-clear
cwd: ~/Desktop/t
Error 2020-10-10 11:28:14: Failed to parse discovered Test [r [Error]: Traceback (most recent call last):
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py", line 17, in <module>
    from testing_tools.adapter.__main__ import parse_args, main
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/__main__.py", line 9, in <module>
    from . import pytest, report
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/__init__.py", line 7, in <module>
    from ._discovery import discover
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

    at ChildProcess.<anonymous> (/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/out/client/extension.js:9:53541)
    at Object.onceWrapper (events.js:313:26)
    at ChildProcess.emit (events.js:223:5)
    at ChildProcess.EventEmitter.emit (domain.js:475:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)]
> ~/Applications/miniconda3/bin/pytest --version
Error 2020-10-10 11:28:14: Python Extension: displayDiscoverStatus [r [Error]: Traceback (most recent call last):
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/run_adapter.py", line 17, in <module>
    from testing_tools.adapter.__main__ import parse_args, main
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/__main__.py", line 9, in <module>
    from . import pytest, report
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/__init__.py", line 7, in <module>
    from ._discovery import discover
  File "/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

    at ChildProcess.<anonymous> (/Users/adefusco/.vscode/extensions/ms-python.python-2020.9.114305/out/client/extension.js:9:53541)
    at Object.onceWrapper (events.js:313:26)
    at ChildProcess.emit (events.js:223:5)
    at ChildProcess.EventEmitter.emit (domain.js:475:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)]
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py jupyter nbconvert --version
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py jupyter nbconvert --version
> ~/Applications/miniconda3/envs/plot/bin/python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py jupyter nbconvert --version
> ~/Applications/miniconda3/envs/plot/bin/python (daemon) -m jupyter nbconvert /var/folders/lk/s__7f9fx15x_zrw6q5xkmm500000gp/T/45b5a54d-be0e-40be-b683-0045c063ac6b/tmp-24986ZT61YC7tA6Bk.ipynb --to python --stdout --template /var/folders/lk/s__7f9fx15x_zrw6q5xkmm500000gp/T/tmp-24986TD26cET8TVOb.tpl

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

bug

All 4 comments

Hi @AlbertDeFusco, thanks for highlighting this. I can repro this bug. I've put up a fix to correct this in microsoft/vscode-python#14360 and the bug fix will be available in our next release. Thanks again for bringing this to our attention!

@cliu268, the bug you linked to is a separate issue鈥攚ould you mind filing a new issue with more details on your Python environment so that we can assist you: https://github.com/microsoft/vscode-python/issues/new?labels=type-bug%2C+data+science&template=1_ds_bug_report.md Many thanks!

Thanks @joyceerhl the issue appears to be with python 3.9 and I found some documented solution here https://discuss.codecademy.com/t/having-trouble-installing-jupyter-notebooks/537292
I am reverting back to 3.7 for now.

Validated

Was this page helpful?
0 / 5 - 0 ratings