Skip to content

Importing a jupyter notebook should show the last output #3403

Closed

Description

@jianboy

Environment data

  • VS Code version: 1.31.1
  • Extension version (available under the Extensions sidebar): 2019.3.6558
  • OS and version: windows10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda

Expected behaviour

jupyter-notebook

Actual behaviour

14

Steps to reproduce:

  1. XXX

Logs

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

XXX

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

XXX

Activity

  1. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor

    Can you paste the code that's causing the problem? Something in the imported code is invalid python.

  2. changed the title [-]Can not render as HTML in the interactive window alongside code and output[/-] on May 20, 2019
  3. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor

    Or even better if you could share the original notebook?

  4. jianboy commented on May 20, 2019

    @jianboy
    Author

    Or even better if you could share the original notebook?

    yes of course. the file is here:

    http://cdn.yoqi.me/direct/2019-05-21/1_hello_tensorflow.ipynb

    THe video of my operation:

    http://cdn.yoqi.me/direct/2019-05-21/Video_2019-05-21_071457_edit.wmv

    I can give you any information you need.

  5. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor

    The import os change working directory stuff we put at the top of the file is messing up the

    from __future__ import print_function
    

    You can just delete the code that looks like this:

    #%% Change working directory from the workspace root to the ipynb file location. Turn this addition off with the DataScience.changeDirOnImportExport setting
    import os
    try:
    	os.chdir(os.path.join(os.getcwd(), '..\Import'))
    	print(os.getcwd())
    except:
    	pass
    

    That code is added to every import if you have this checked:
    image

    Otherwise I'm having trouble getting tensorflow to run. I keep getting this:

    image

  6. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor

    Yeah it looks like tensorflow doesn't have session anymore. I must have installed too new of a tensorflow

    tensorflow/tensorflow#26816

  7. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor

    Oh but you don't click on the tensorflow cell. So maybe my advice didn't matter. You're clicking on this cell in your gif:

    image

    And that is failing, possibly because you're using Python 2?

    However in the video you posted, you mentioned the entire file wasn't there? Were you hoping it would open up the file as a jupyter notebook inside of VS Code?

    Unfortunately the product doesn't work that way at the moment. Currently we expect you to work with '.py' files. The import notebook command merely extracts your python code.

    We do have another open issue on inline notebooks though.
    https://github.com/microsoft/vscode-python/issues/4575

  8. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor
  9. jianboy commented on May 20, 2019

    @jianboy
    Author

    Yeah it looks like tensorflow doesn't have session anymore. I must have installed too new of a tensorflow

    tensorflow/tensorflow#26816

    The function I want is just to preview the file when I open a jupyter file. and can run code.

  10. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor

    I don't believe we have what you want (yet). Importing a notebook just turns it into the python code in your notebook. You then have to run each cell to view the output in the other pane.

  11. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor

    If the hydrogen thing meets your needs, feel free to up vote the issue we have that I linked:
    microsoft/vscode-python#4575

  12. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor

    In the video you mention the 'right cannot display the html'. Can you elaborate on that comment? What HTML did you want? (Just wondering what we should do when we implement the hydrogen support)

  13. jianboy commented on May 20, 2019

    @jianboy
    Author

    In the video you mention the 'right cannot display the html'. Can you elaborate on that comment? What HTML did you want? (Just wondering what we should do when we implement the hydrogen support)

    thank you, I want preview the whole jupyter file. I hope that we can get this feature out quickly.

  14. jianboy commented on May 20, 2019

    @jianboy
    Author

    when can I preview a jupyter file code ? I read Introduction of our plugin. it show have the function.

    image

  15. rchiodo commented on May 20, 2019

    @rchiodo
    Contributor

    It does this now. All you have to do is click on the 'Run Below' command at the very top. That will run all 'cells' in the imported notebook. That's what the docs are showing anyway.

    You probably want to uncheck this setting before you do the import though.
    image

  16. 1 remaining item

  17. jianboy commented on May 21, 2019

    @jianboy
    Author

    I often need to look at the contents of the jupyter file and then consider whether execute it.

  18. rchiodo commented on May 21, 2019

    @rchiodo
    Contributor

    Oh you want to see the current output. The last run you mean?

  19. rchiodo commented on May 21, 2019

    @rchiodo
    Contributor

    Our current implementation requires a rerun on every open. It's more like a terminal than a notebook viewer.

  20. jianboy commented on May 21, 2019

    @jianboy
    Author

    Oh you want to see the current output. The last run you mean?

    yes, you are right.

  21. rchiodo commented on May 21, 2019

    @rchiodo
    Contributor

    Hmm, that might be possible sooner (before we do the hydrogen thing). On import, just fill the interactive window with the current output.

  22. jianboy commented on May 21, 2019

    @jianboy
    Author

    the plugin can privew the jupyter file. but can not run code.
    https://marketplace.visualstudio.com/items?itemName=jithurjacob.nbpreviewer

  23. changed the title [-]Importing a jupyter notebook is not generating correct code[/-] on May 21, 2019
  24. rchiodo commented on May 21, 2019

    @rchiodo
    Contributor

    Thanks. That's super helpful.

  25. jianboy commented on May 21, 2019

    @jianboy
    Author

    I think if vscode can preview jupyter file ,and can run it. it may be better than the web page of jupyter notebook.

  26. locked as resolved and limited conversation to collaborators on Aug 14, 2019
  27. unlocked this conversation on Nov 14, 2020
  28. locked as resolved and limited conversation to collaborators on May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions