vscode-jupyter
vscode-jupyter copied to clipboard
Click out from Az ML Studio to VS Code doesn't select the right environment.
Applies To
- [X] Notebooks (.ipynb files)
- [ ] Interactive Window and/or Cell Scripts (.py files with #%% markers)
What happened?
- Open a notebook in Azure ML Studio.
- Run a cell or two. In particular run this code:
import sys
sys.version
Take note of the python version. In my case it's 3.8.5 (default, Sep 4 2020, 07:30:14) \n[GCC 7.3.0]
-
Click out to VS Code using the button at the top of the notebook

-
After the notebook opens in VS Code, run the same cell as above. In my case I get:
3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
I.e. In the Az ML Studio I'm running with Python 3.8.5, but on VS Code I default to 3.8.10.
The expectation is that VS Code chooses the same environment as was being used on Az ML Studio. Bonus points if we could connect to the actual running kernel, but that isn't necessary right now.
VS Code Version
Version: 1.70.1 (system setup) Commit: 6d9b74a70ca9c7733b29f0456fd8195364076dda Date: 2022-08-10T06:08:33.642Z Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Windows_NT x64 10.0.25188
Jupyter Extension Version
v2022.7.1102252217
Jupyter logs
Visual Studio Code (1.70.1, amlext, desktop)
Jupyter Extension Version: 2022.7.1102252217.
Python Extension Version: 2022.12.1.
Workspace folder /home/azureuser/cloudfiles/code
info 17:49:7.226: ZMQ install verified.
User belongs to experiment group 'jupyterTest'
User belongs to experiment group 'jupyterEnhancedDataViewer'
info 17:49:7.984: LSP Notebooks experiment is disabled -- not using Pylance
error 17:49:8.742: getCondaFile, Class name = w, completed in 752ms, has a falsy return value [Unknown (FileSystemError) (FileSystemError): Error: EINVAL: invalid argument, stat 'c:\Users\jimg\anaconda3\Scripts\conda.exe'
at Function._handleError (/home/azureuser/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda/out/vs/workbench/api/node/extensionHostProcess.js:87:30174)
at Object.stat (/home/azureuser/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda/out/vs/workbench/api/node/extensionHostProcess.js:87:28102)
at async f.getFileHash (/home/azureuser/.vscode-server/extensions/ms-toolsai.jupyter-2022.7.1102252217/out/extension.node.js:7:17708)
at async w.getCachedInformation (/home/azureuser/.vscode-server/extensions/ms-toolsai.jupyter-2022.7.1102252217/out/extension.node.js:7:35788)] {
code: 'Unknown'
}
error 17:49:8.745: getCondaVersion, Class name = w, completed in 755ms, has a falsy return value [Unknown (FileSystemError) (FileSystemError): Error: EINVAL: invalid argument, stat 'c:\Users\jimg\anaconda3\Scripts\conda.exe'
at Function._handleError (/home/azureuser/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda/out/vs/workbench/api/node/extensionHostProcess.js:87:30174)
at Object.stat (/home/azureuser/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda/out/vs/workbench/api/node/extensionHostProcess.js:87:28102)
at async f.getFileHash (/home/azureuser/.vscode-server/extensions/ms-toolsai.jupyter-2022.7.1102252217/out/extension.node.js:7:17708)
at async w.getCachedInformation (/home/azureuser/.vscode-server/extensions/ms-toolsai.jupyter-2022.7.1102252217/out/extension.node.js:7:35788)] {
code: 'Unknown'
}
info 17:49:8.772: Starting Jupyter Session id = 'startUsingPythonInterpreter:.jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher' (Python Path: , EnvType: Global, EnvName: '', Version: 3.8.10) for '/home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb' (disableUI=true)
info 17:49:8.775: Creating raw notebook for resource '/home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb'
info 17:49:8.776: Computing working directory for resource '/home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb'
info 17:49:8.864: Starting raw kernel 'Python 3.8.10 64-bit' for interpreter /usr/bin/python3
info 17:49:8.870: Kernel launching with ports 9000,9001,9002,9003,9004. Start port is 9000
info 17:49:9.447: Experiment status for python is {"enabled":true,"optInto":[],"optOutFrom":[]}
info 17:49:9.499: Registering dummy command feature
info 17:49:10.117: No custom variables nor do we have a conda environment
info 17:49:10.135: Process Execution: > /usr/bin/python3 -m pip list
> /usr/bin/python3 -m pip list
info 17:49:10.148: Process Execution: > /usr/bin/python3 -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> /usr/bin/python3 -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 17:49:10.161: Process Execution: > /usr/bin/python3 -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"8a3abc07-da0b-4e8c-893c-095752df9fdf" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/azureuser/.local/share/jupyter/runtime/kernel-v2-131468m6Cv1yM7S6Oa.json
> /usr/bin/python3 -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"8a3abc07-da0b-4e8c-893c-095752df9fdf" --shell=9002 --transport="tcp" --iopub=9004 --f=/home/azureuser/.local/share/jupyter/runtime/kernel-v2-131468m6Cv1yM7S6Oa.json
info 17:49:10.161: Process Execution: cwd: ~/cloudfiles/code/Users/jimgries
cwd: ~/cloudfiles/code/Users/jimgries
info 17:49:10.198: Process Execution: > /usr/bin/python3 -c "import pip"
> /usr/bin/python3 -c "import pip"
info 17:49:10.308: Preferred Remote kernel for /home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb is undefined
info 17:49:10.308: Find preferred kernel for /home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb with metadata {"kernel_info":{"name":"python3"},"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.8.10"},"nteract":{"version":"[email protected]"},"orig_nbformat":4,"vscode":{"interpreter":{"hash":"31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"}}} & preferred interpreter /anaconda/envs/azureml_py38/bin/python
info 17:49:10.328: Preferred Remote kernel for /home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb is undefined
info 17:49:10.329: Preferred kernel .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher is exact match or top match for non python kernels, (false, undefined, true, false)
info 17:49:10.330: PreferredConnection: .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher found for NotebookDocument: /home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb
info 17:49:10.803: ipykernel version 5.2.0 for /usr/bin/python3
info 17:49:10.803: ipykernel location /usr/lib/python3/dist-packages/ipykernel/__init__.py for /usr/bin/python3
info 17:49:10.817: Preferred Remote kernel for /home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb is undefined
info 17:49:10.878: Kernel Output: NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.
To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.
To read more about this, see https://github.com/ipython/ipython/issues/2049
To connect another client to this kernel, use:
--existing kernel-v2-131468m6Cv1yM7S6Oa.json
warn 17:49:10.940: StdErr from Kernel Process [IPKernelApp] WARNING | Unknown error in handling startup files:
info 17:49:10.946: Started kernel Python 3.8.10 64-bit., (Raw session started and connected)
info 17:49:10.947: Finished connecting a990050c-c8c2-4e70-849c-cf9f73572f5d
info 17:49:10.963: Registering dummy command feature
info 17:49:10.996: UpdateWorkingDirectoryAndPath in Kernel
info 17:49:10.997: Executing silently Code (busy) = import os\nimport sys\n%cd "//home/azureuser/cloudfiles/code/Users/jimgries"\nif os.getcwd() not in sys
info 17:49:11.546: Executing silently Code (completed) = import os\nimport sys\n%cd "//home/azureuser/cloudfiles/code/Users/jimgries"\nif os.getcwd() not in sys with 1 output(s)
info 17:49:11.547: Waiting for idle on (kernel): 685748af-16b5-411d-9eef-81a0aafe5ed6 -> idle
info 17:49:11.547: Finished waiting for idle on (kernel): 685748af-16b5-411d-9eef-81a0aafe5ed6 -> idle
info 17:49:11.569: Process Execution: > /usr/bin/python3 ~/.vscode-server/extensions/ms-toolsai.jupyter-2022.7.1102252217/pythonFiles/printJupyterDataDir.py
> /usr/bin/python3 ~/.vscode-server/extensions/ms-toolsai.jupyter-2022.7.1102252217/pythonFiles/printJupyterDataDir.py
info 17:49:11.690: Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
info 17:49:11.690: Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
info 17:49:11.734: Execute Cell 0 /home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb
info 17:49:11.740: Widget Message: data-base-url set to https://vscode-remote%2Bamlext-002b2f737562736372697074696f6e732f32376465366265312d643532342d343466322d396139352d3130616233333634366363372f7265736f7572636547726f7570732f6a696d67726965732d72672f70726f7669646572732f4d6963726f736f66742e4d616368696e654c6561726e696e6753657276696365732f776f726b7370616365732f6a696d67726965732d63616e6172792d77732f636f6d70757465732f6a696d67726965732d636931.vscode-resource.vscode-cdn.net/home/azureuser/.vscode-server/extensions/ms-toolsai.jupyter-2022.7.1102252217/tmp/scripts/31287cf9e2e18afa40154cd18cb1e57335b009e6bfea9730c6beb09c8a1ec8b0/jupyter
info 17:49:11.884: Cell 0 executed with state Success
info 17:49:12.578: Process Execution: > /anaconda/envs/azureml_py38/bin/python -m pip list
> /anaconda/envs/azureml_py38/bin/python -m pip list
info 17:49:44.588: Execute Cell 0 /home/azureuser/cloudfiles/code/Users/jimgries/notebook.ipynb
info 17:49:44.728: Cell 0 executed with state Success
Coding Language and Runtime Version
No response
Language Extension Version (if applicable)
No response
Anaconda Version (if applicable)
No response
Running Jupyter locally or remotely?
No response
Hmm, seems interesting the metadata is actually already specified here:
But in the log above it looked like it was searching with different metadata. Will dig in more.
info 22:13:44.449: Experiment status for python is {"enabled":true,"optInto":[],"optOutFrom":[]} info 22:13:44.589: Preferred Remote kernel for /home/azureuser/cloudfiles/code/Users/ianhu/Continue3.ipynb is undefined info 22:13:44.589: Find preferred kernel for /home/azureuser/cloudfiles/code/Users/ianhu/Continue3.ipynb with metadata {"kernelspec":{"name":"python38-azureml","language":"python","display_name":"Python 3.8 - AzureML"},"language_info":{"name":"python","version":"3.8.5","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kernel_info":{"name":"python38-azureml"},"nteract":{"version":"[email protected]"}} & preferred interpreter /usr/bin/python3 info 22:13:44.591: Preferred Remote kernel for /home/azureuser/cloudfiles/code/Users/ianhu/Continue3.ipynb is undefined info 22:13:44.591: Preferred kernel .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher is exact match or top match for non python kernels, (false, [object Object], false, false) info 22:13:44.592: PreferredConnection: .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher found for NotebookDocument: /home/azureuser/cloudfiles/code/Users/ianhu/Continue3.ipynb
Interesting, just redid the scenario and it worked out perfectly, timing issue?
info 22:30:43.62: Preferred Remote kernel for /home/azureuser/cloudfiles/code/Users/ianhu/NewName.ipynb is undefined
info 22:30:43.62: Find preferred kernel for /home/azureuser/cloudfiles/code/Users/ianhu/NewName.ipynb with metadata {"kernelspec":{"name":"python38-azureml","language":"python","display_name":"Python 3.8 - AzureML"},"language_info":{"name":"python","version":"3.8.5","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kernel_info":{"name":"python38-azureml"},"nteract":{"version":"[email protected]"}} & preferred interpreter /usr/bin/python3
info 22:30:43.75: Preferred Remote kernel for /home/azureuser/cloudfiles/code/Users/ianhu/NewName.ipynb is undefined
info 22:30:43.75: Preferred kernel .python38-azureml./anaconda/envs/azureml_py38/python./anaconda/envs/azureml_py38/python.-m#ipykernel_launcher is exact match or top match for non python kernels, (false, undefined, true, false)
info 22:30:43.76: PreferredConnection: .python38-azureml./anaconda/envs/azureml_py38/python./anaconda/envs/azureml_py38/python.-m#ipykernel_launcher found for NotebookDocument: /home/azureuser/cloudfiles/code/Users/ianhu/NewName.ipynb
@IanMatthewHuff
the scenario and it worked out perfectly, timing issue?
I think yes, see here https://github.com/microsoft/vscode-jupyter/issues/10900#issuecomment-1212302687 This test fails pretty reliably due to a race condition. I haven't checked the code since, but need to see if this falls into my area, let me know if thats the case.
This should now be fixed