You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Importing a jupyter notebook should show the last output #3403
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
Actual behaviour
Steps to reproduce:
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)
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:
Otherwise I'm having trouble getting tensorflow to run. I keep getting this:
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:
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.
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.
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)
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.
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.
Activity
rchiodo commentedon May 20, 2019
Can you paste the code that's causing the problem? Something in the imported code is invalid python.
[-]Can not render as HTML in the interactive window alongside code and output[/-]rchiodo commentedon May 20, 2019
Or even better if you could share the original notebook?
jianboy commentedon May 20, 2019
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.
rchiodo commentedon May 20, 2019
The import os change working directory stuff we put at the top of the file is messing up the
You can just delete the code that looks like this:
That code is added to every import if you have this checked:

Otherwise I'm having trouble getting tensorflow to run. I keep getting this:
rchiodo commentedon May 20, 2019
Yeah it looks like tensorflow doesn't have session anymore. I must have installed too new of a tensorflow
tensorflow/tensorflow#26816
rchiodo commentedon May 20, 2019
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:
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
rchiodo commentedon May 20, 2019
Something like this:
https://atom.io/packages/hydrogen
jianboy commentedon May 20, 2019
The function I want is just to preview the file when I open a jupyter file. and can run code.
rchiodo commentedon May 20, 2019
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.
rchiodo commentedon May 20, 2019
If the hydrogen thing meets your needs, feel free to up vote the issue we have that I linked:
microsoft/vscode-python#4575
rchiodo commentedon May 20, 2019
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)
jianboy commentedon May 20, 2019
thank you, I want preview the whole jupyter file. I hope that we can get this feature out quickly.
jianboy commentedon May 20, 2019
when can I preview a jupyter file code ? I read Introduction of our plugin. it show have the function.
rchiodo commentedon May 20, 2019
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.

1 remaining item
jianboy commentedon May 21, 2019
I often need to look at the contents of the jupyter file and then consider whether execute it.
rchiodo commentedon May 21, 2019
Oh you want to see the current output. The last run you mean?
rchiodo commentedon May 21, 2019
Our current implementation requires a rerun on every open. It's more like a terminal than a notebook viewer.
jianboy commentedon May 21, 2019
yes, you are right.
rchiodo commentedon May 21, 2019
Hmm, that might be possible sooner (before we do the hydrogen thing). On import, just fill the interactive window with the current output.
jianboy commentedon May 21, 2019
the plugin can privew the jupyter file. but can not run code.
https://marketplace.visualstudio.com/items?itemName=jithurjacob.nbpreviewer
[-]Importing a jupyter notebook is not generating correct code[/-]rchiodo commentedon May 21, 2019
Thanks. That's super helpful.
jianboy commentedon May 21, 2019
I think if vscode can preview jupyter file ,and can run it. it may be better than the web page of jupyter notebook.