microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 292 forks source link

Markdown cell not rendering in python interactive window if no internet connection #1331

Closed rlevitin closed 3 years ago

rlevitin commented 5 years ago

Environment data

VS Code Version: 1.37.0-insider Extension Version: 2019.6.242221 OS - Windows 10 17763.615. Using remote development 0.15.0 to run code on a linux box Python 3.6.8 64-bit with anaconda (conda env)

Expected behaviour

When I run a markdown code block, it should display the text as markdown in the python interactive viewer.

Actual behaviour

A blank cell loads with no output. Regular python code blocks run as expected. Markdown just comes up blank.

Steps to reproduce:

  1. Create a new file "test.py"
  2. Code block
    
    #%% [markdown]
    # Test Print
    # This should print out
    # ## This should print as a heading

%%

print("Test")


## Logs
Output for `Python` in the `Output` panel:

Starting Microsoft Python language server. Starting Jedi Python language engine.


Output from `Console`:

workbench.main.js:242 [Extension Host] Info Python Extension: 2019-08-05 11:31:02: Submitting code for 364114ed-361f-4257-8d33-a094d695fea0 workbench.main.js:242 [Extension Host] Info Python Extension: 2019-08-05 11:31:02: Waiting for jupyter server and web panel ... 2 workbench.main.js:242 [Extension Host] Info Python Extension: 2019-08-05 11:31:02: Wait for sys info for 364114ed-361f-4257-8d33-a094d695fea0 0 workbench.main.js:242 [Extension Host] Info Python Extension: 2019-08-05 11:31:02: Finished execution for 62bff78a-274a-4fd2-b722-08b5935188d9 workbench.main.js:242 [Extension Host] rejected promise not handled within 1 second: TypeError: Cannot read property 'version' of undefined workbench.main.js:242 [Extension Host] stack trace: TypeError: Cannot read property 'version' of undefined at f.getLanguageServerFolderName (/home/rlevitin/.vscode-server-insiders/extensions/ms-python.python-2019.6.24221/out/client/extension.js:75:111924) at process._tickCallback (internal/process/next_tick.js:68:7) workbench.main.js:3414 [[object Object]]Cannot read property 'version' of undefined workbench.main.js:3414 TypeError: Cannot read property 'version' of undefined at f.getLanguageServerFolderName (/home/rlevitin/.vsco…ent/extension.js:75) at process._tickCallback (internal/process/next_tick.js:68) workbench.main.js:3038 [Embedded Page] Uncaught ReferenceError: MathJax is not defined workbench.main.js:242 [Extension Host] rejected promise not handled within 1 second: TypeError: Cannot read property 'version' of undefined workbench.main.js:242 [Extension Host] stack trace: TypeError: Cannot read property 'version' of undefined at f.getLanguageServerFolderName (/home/rlevitin/.vscode-server-insiders/extensions/ms-python.python-2019.6.24221/out/client/extension.js:75:111924) at process._tickCallback (internal/process/next_tick.js:68:7) workbench.main.js:3414 [[object Object]]Cannot read property 'version' of undefined workbench.main.js:3414 TypeError: Cannot read property 'version' of undefined at f.getLanguageServerFolderName (/home/rlevitin/.vsco…ent/extension.js:75) at process._tickCallback (internal/process/next_tick.js:68) workbench.main.js:242 [Extension Host] ApplicationInsights:Sender Array(2) DevTools failed to parse SourceMap: https://ticino.blob.core.windows.net/sourcemaps/92da68a…/core/vs/workbench/workbench.main.js.map



![image](https://user-images.githubusercontent.com/1235172/62475938-10f39900-b774-11e9-9cfc-22ea052785c0.png)

I have looked at Issue microsoft/vscode-python#3108. The output looks to be a similar problem but my machine is not offline... not sure why this is happening. It was working fine last week.
rchiodo commented 5 years ago

If you go to 'Developer : Open Webview Developer Tools' and look at the console output there, does it show anything?

rlevitin commented 5 years ago

When I try to run a cell block this pops up:

load-script.js:52 GET https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML net::ERR_CERT_AUTHORITY_INVALID

context.js:50 Uncaught ReferenceError: MathJax is not defined
    at eval (context.js:50)
    at HTMLScriptElement.script.onerror (load-script.js:71)
rchiodo commented 5 years ago

Can you navigate to that website (mathjax)?

https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML

That's where the code for displaying markdown lives.

rchiodo commented 5 years ago

I wonder if we could use this instead of the nteract transform: https://www.npmjs.com/package/mathjax

rlevitin commented 5 years ago

Yes, it loads for me on my computer. I'm remote-coding on a linux box, and if I run

wget -q --spider https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML; echo $? It returns 0, telling me the remote system can reach the page without issues as well

rlevitin commented 5 years ago

Is there anyway for me on the user side to point it to a different mathjax source? (these are all things I'm not familiar with)

rchiodo commented 5 years ago

Sorry, not without rebuilding and changing our source. We're using nteract to display markdown and it's pulling in the cdnjs.cloudfare.com location to render markdown.

rchiodo commented 5 years ago

The request should be happening on your local machine though. That's where the code is loading the markdown.

janosh commented 5 years ago

I wonder if we could use this instead of the nteract transform: https://www.npmjs.com/package/mathjax

That seems like a good idea! Although I'd recommend KaTeX made by Khan Academy (NPM) over MathJax.

greazer commented 5 years ago

Changing this would also fix the problem of the extension needing access to the internet for markdown (nteract's implementation does this)

rlevitin commented 5 years ago

I think that it is an issue with the internet connection. It's clear that there is some sort of issue with the firewall at work. I think the suggested fix will help.

Not sure if I should open a new issue for this, but another thing I have noticed is relative image links in Markdown (when Markdown does work) looks for the file in the local file system rather than the remote file system and obviously can't find the files. I'm not sure whether this would be an issue to solve in the python extension or the remote coding extension.

For example, see screenshot below. "notebook_ims/conv_layer.gif" is located on the remote filesystem but can't be found for rendering locally.

image

rchiodo commented 5 years ago

I don't think the relative file path is going to work with the remote VS Code. The markdown is running on your local machine so there's no way to find the files. VS Code's Webview API doesn't have a file access API yet, so until they add that it won't be able to find the files.

Chuxel commented 5 years ago

I don't think the relative file path is going to work with the remote VS Code. The markdown is running on your local machine so there's no way to find the files. VS Code's Webview API doesn't have a file access API yet, so until they add that it won't be able to find the files.

If the extension is running remotely and populating the webview, it should work. Similarly, if this is coming off of a remote web server, relative paths should work as well. However, you can't mix local content with remote content. In this case it sounds like everything is on the remote side. The WebView content is served up from the remote side much like browser would interact with a web server.

rlevitin commented 5 years ago

I realized that I am actually still having the same problem if running locally, and I think it is an issue with the python extension and not with running vscode remote

image


[Extension Host] Kernel: connected (f6fd530c-8883-4b37-9346-e9533fd631e1)
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 15:08:11: Finished waiting for idle on: f6fd530c-8883-4b37-9346-e9533fd631e1idle
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 15:08:14: Cached data exists getEnvironmentVariables, c:\Users\rlevi\OneDrive\Coding\deep-learning-v2-pytorch\recurrent-neural-networks\char-rnn
2
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 15:08:14: > /home/rlevitin/anaconda3/envs/style-transfer/bin/python -c "import sys;print(sys.executable)"
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 15:08:15: Submitting code for b3a19f0d-ef5d-4427-ad00-41ce447482fc
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 15:08:15: Waiting for jupyter server and web panel ...
2
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 15:08:15: Wait for sys info for b3a19f0d-ef5d-4427-ad00-41ce447482fc 0
console.ts:137 [Extension Host] Info Python Extension: 2019-08-19 15:08:15: Finished execution for ab1edc3d-8565-48ca-8caa-c025213239ef
resourceLoader.ts:37 g: Unable to read file (Error: File not found (c:\Users\rlevi\.vscode\extensions\ms-python.python-2019.8.30787\out\datascience-ui\history-react\assets\charRNN.png))
    at b.<anonymous> (file:///C:/Users/rlevi/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:1466:7)
    at Generator.throw (<anonymous>)
    at a (file:///C:/Users/rlevi/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:35:344)

Note the problem is that it is unable to read the image file as it is looking for the file in the history-react folder under the extension, rather than in my working directory/path (you can see in the explorer pane the folders that are present.

SheepDomination commented 5 years ago

I too cannot compile # or * without a syntax error using #%%markdown or #%%[markdown] in a cell ?

rchiodo commented 5 years ago

@SheepDomination in order to have code that doesn't give you a linter error, you need to put a space between the # and the %%[markdown].

Like so:

image

First cell has an error, second doesn't. We changed our default comment to have a space now.

joyceerhl commented 3 years ago

Closing as VS Code ships KaTeX for markdown math rendering and doesn't rely on downloading MathJax. The new native interactive window relies on VS Code for markdown rendering. Please file a bug at https://github.com/microsoft/vscode if something isn't working.