Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't start Python interactive viewer for Jupyter cell #3794

Closed
pauloneves opened this issue Nov 14, 2018 · 10 comments
Closed

Can't start Python interactive viewer for Jupyter cell #3794

pauloneves opened this issue Nov 14, 2018 · 10 comments
Assignees

Comments

@pauloneves
Copy link

Environment data

  • VS Code version: 1.29.0
  • Extension version (available under the Extensions sidebar): 2018.10.1 (09 Nov 2018)
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7 Anaconda
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: Jupyter notebook

Actual behavior

Try to execute cell in imported python notebook. Python interactive doesn't start and freezes.

Expected behavior

The selected cell should have been executed in the Python Interactive pane.

Steps to reproduce:

  1. Open VSCode from an activated conda env in a dos shell

  2. Right click a .ipynb file and select "Import Jupyter Notebook"

  3. In the first code cell of the imported file file there is a Run Cell option.:
    image

  4. Click Run Cell and in the status bar appears a message that the Jupyter Server is starting:
    image

  5. The editing pane is vertically split and a new tab named "Python Interactive" appears with a blue bar moving horizontally
    image

  6. Nothing happens, Code isn't executed. blue bar keeps rolling. Status bar stays with "starting..." message.

Logs

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

Starting Microsoft Python language server.
Microsoft Python Language Server version 0.1.60.0
Initializing for D:\Anaconda3\envs\xxx\python.exe

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

In the log below, there is an error (I don't have any Anaconda in C:)

console.ts:134 [Extension Host] Failed to get interpreter information for 'C:\Program Files\Anaconda\python.exe' Error: spawn C:\Program Files\Anaconda\python.exe ENOENT
	at _errnoException (util.js:1024:11)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
	at onErrorNT (internal/child_process.js:372:16)
	at _combinedTickCallback (internal/process/next_tick.js:138:11)
	at process._tickCallback (internal/process/next_tick.js:180:9)
t.log @ console.ts:134

There is the complete log.

extensionService.ts:1009 [PKief.markdown-checkbox]: Menu item references the same command as default and alt-command
TMSyntax.ts:47 Overwriting grammar scope name to file mapping for scope source.yaml.
Old grammar file: file:///d%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/yaml/syntaxes/yaml.tmLanguage.json.
New grammar file: file:///c%3A/Users/PauloEduardo/.vscode/extensions/redhat.vscode-yaml-0.1.0/syntaxes/yaml.tmLanguage.json
e.register @ TMSyntax.ts:47
log.ts:157  INFO no standard startup: panel is active
console.ts:134 [Extension Host]% Array(66)
console.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Create file systemwatcher with pattern *\python.exe
console.ts:134 [Extension Host] Python Extension: Create file systemwatcher with pattern *\*\python.exe
console.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Create file systemwatcher with pattern *\python.exe
console.ts:134 [Extension Host] Python Extension: Create file systemwatcher with pattern *\*\python.exe
console.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Register Intepreter Watcher, Arg 1: {"$mid":1,"fsPath":"d:\\dev\\xxx","external":"file:///d%3A/dev/xxx","path":"/d:/dev/xxx","scheme":"file"}, Return Value: 
console.ts:134 [Extension Host] Python Extension: Register Intepreter Watcher, Arg 1: undefined, Return Value: 
console.ts:134 [Extension Host] Python Extension: Build the workspace interpreter watcher, Arg 1: {"$mid":1,"fsPath":"d:\\dev\\xxx","external":"file:///d%3A/dev/xxx","path":"/d:/dev/xxx","scheme":"file"}, Return Value: UNABLE TO DETERMINE VALUE
console.ts:134 [Extension Host] Python Extension: Build the workspace interpreter watcher, Arg 1: undefined, Return Value: UNABLE TO DETERMINE VALUE
console.ts:134 [Extension Host] Python Extension: Get language server folder name, , Return Value: "languageServer.0.1.60"
console.ts:134 [Extension Host] Failed to get interpreter information for 'C:\Program Files\Anaconda\python.exe' Error: spawn C:\Program Files\Anaconda\python.exe ENOENT
	at _errnoException (util.js:1024:11)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
	at onErrorNT (internal/child_process.js:372:16)
	at _combinedTickCallback (internal/process/next_tick.js:138:11)
	at process._tickCallback (internal/process/next_tick.js:180:9)
t.log @ console.ts:134
t._logExtensionHostMessage @ extensionHost.ts:437
(anonymous) @ extensionHost.ts:244
emitTwo @ events.js:126
emit @ events.js:214
emit @ internal/child_process.js:772
_combinedTickCallback @ internal/process/next_tick.js:141
_tickCallback @ internal/process/next_tick.js:180
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Git extension API method 'getGitPath' is deprecated.
t.log @ console.ts:134
t._logExtensionHostMessage @ extensionHost.ts:437
(anonymous) @ extensionHost.ts:244
emitTwo @ events.js:126
emit @ events.js:214
emit @ internal/child_process.js:772
_combinedTickCallback @ internal/process/next_tick.js:141
_tickCallback @ internal/process/next_tick.js:180
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: 
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: 
console.ts:134 [Extension Host] Python Extension: [W 22:42:55.354 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.

console.ts:134 [Extension Host] Python Extension: [I 22:42:55.419 NotebookApp] Serving notebooks from local directory: C:\Users\PAULOE~1\AppData\Local\Temp

console.ts:134 [Extension Host] Python Extension: [I 22:42:55.419 NotebookApp] The Jupyter Notebook is running at:
[I 22:42:55.419 NotebookApp] http://(i7 or 127.0.0.1):8888/?token=6d81d530b1ffe2413845b87d86a3372c4d9b63f50ad6a2d8
[I 22:42:55.420 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

console.ts:134 [Extension Host] Python Extension: [C 22:42:55.425 NotebookApp] 
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://(i7 or 127.0.0.1):8888/?token=6d81d530b1ffe2413845b87d86a3372c4d9b63f50ad6a2d8

console.ts:134 [Extension Host] Python Extension: [I 22:44:45.845 NotebookApp] 302 GET /?token=6d81d530b1ffe2413845b87d86a3372c4d9b63f50ad6a2d8 (::1) 0.00ms
@pauloneves
Copy link
Author

Some more info:

  • I've selected the conda env python executable in VSCode, so "python.pythonPath" is set in settings.json
  • I can connect to the jupyter notebook using my web browser.

@DonJayamanne
Copy link
Contributor

console.ts:134 [Extension Host] Failed to get interpreter information for 'C:\Program Files\Anaconda\python.exe' Error: spawn C:\Program Files\Anaconda\python.exe ENOENT at _errnoException (util.js:1024:11)

@rchiodo
We've seen this message in the past in the extension. On Windows this was due to the user having some funky paths with double quotes ".

@pauloneves
Please could you check your environment variable PATH and ensure there are no invalid entries in there.

  • Ensure all paths are valid
  • Ensure there are no empty entries
  • Ensure there are no paths with double quotes

@pauloneves
Copy link
Author

@DonJayamanne

The error persists.

* Ensure all paths are valid
* Ensure there are no empty entries

Checked this way:

In [1]: from pathlib import Path
In [2]: import os`
In [3]: for i in os.environ['PATH'].split(';'):
   ...:     if not Path(i).exists():
   ...:         print(i)

Some paths were printed. I removed 2. Other two were d:\Anaconda3\envs\myenv\bin and d:\Anaconda3\envs\myenv\Library\usr\bin and I created them manually.

* Ensure there are no paths with double quotes

There's none.

The little code above now doesn't print anything.

@pauloneves
Copy link
Author

The linked bugs say that VSCode complains that Jupyter is not installed. I've also got this error and installed jupyter with conda install jupyter in my activated environment shell. Then I got the frozen interactive pane that I described.

If I start VSCode outside the conda virtual env, it complains again that Jupyter is not installed. I installed Jupyter outside any env, restart VSCode and it still complains.

I had a similar problem with rope, that VSCode wouldn't recognize it installed. Just after I installed with PIP that VSCode found it.

@rchiodo
Copy link
Contributor

rchiodo commented Nov 15, 2018

I think the root cause is this:

http://(i7 or 127.0.0.1):8888/?token=6d81d530b1ffe2413845b87d86a3372c4d9b63f50ad6a2d8

We match on a regex that expects something like this:

http://127.0.0.1:8888/?token=6d81d530b1ffe2413845b87d86a3372c4d9b63f50ad6a2d8

Not sure why you have a different output than others, but we'll have to search for different strings for the startup to work.

@pauloneves
Copy link
Author

pauloneves commented Nov 15, 2018 via email

@rchiodo
Copy link
Contributor

rchiodo commented Nov 15, 2018

Actually the regex doesn't match 127.0.0.1 either. It assumes localhost:

This is the regex.
/http://localhost:[0-9]+/?token=[a-z0-9]+/

@IanMatthewHuff
Copy link
Member

In addition to handling the IP case we need to handle the OR case.
jupyter/notebook#3703

User can also change the display URL manually:
https://github.com/jupyter/notebook/pull/3668/files

@pauloneves
Copy link
Author

Actually the regex doesn't match 127.0.0.1 either. It assumes localhost:

This is the regex.
/http://localhost:[0-9]+/?token=[a-z0-9]+/

I changed the url to localhost and everything worked!!! Thanks!

@IanMatthewHuff
Copy link
Member

@pauloneves. With this PR: microsoft/vscode-python#3386
I've expanded our address handling. It should now be fine with localhost, IP, missing token values, and base_url values.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 18, 2018
@microsoft microsoft unlocked this conversation Nov 14, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants