microsoft / vscode-jupyter

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

Cannot select current python interpreter as kernel #15938

Open pculbertson-bdai opened 4 weeks ago

pculbertson-bdai commented 4 weeks ago

Applies To

What happened?

Using the suggested (but complicated) workflow to pick a custom interpreter, I run:

Ironically, I can run Jupyter: Create Interactive Window which connects just fine. I just can't run an existing notebook :upside_down_face:

I should note my workflow is pretty nontraditional -- I'm using a python executable built with Bazel that changes some paths etc on startup. But still, I can run it fine from the command line + sometimes can pick it as a kernel using the above workflow -- it just stopped working randomly today (possibly due to a clean rebuild).

Really appreciate your help + sorry if my workflow is silly. This is a possible duplicate of many issues also (#15086, #15087, and their duplicates).

VS Code Version

1.92.0

Jupyter Extension Version

2024.7.0

Jupyter logs

Visual Studio Code (1.92.0, attached-container, desktop)
Jupyter Extension Version: 2024.7.0.
Python Extension Version: 2024.12.1.
Pylance Extension Version: 2024.8.1.
Platform: linux (x64).
Workspace folder ~/starfish, Home = /home/pculbertson_theaiinstitute_com
14:58:19.945 [debug] Start refreshing Kernel Picker (1723733899944)
14:58:20.335 [debug] Get Custom Env Variables, Class name = Sm, completed in 391ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunPythonCode"
14:58:20.335 [debug] Jupyter Paths /kernels: 
14:58:20.335 [debug] Kernel Spec Root Paths, /usr/share/jupyter/kernels, /usr/local/share/jupyter/kernels, ~/.local/share/jupyter/kernels
14:58:20.491 [debug] End refreshing Kernel Picker (1723733899944)
14:58:20.717 [debug] KernelProvider switched kernel to id = .jvsc74a57bd0767d51c1340bd893661ea55ea3124f6de3c7a262a8b4abca0554b478b1e2ff90./usr/bin/python./usr/bin/python.-m#ipykernel_launcher
14:58:20.717 [debug] start the kernel, options.disableUI=true for ~/starfish/dexterity/gaussian_splatting/sam2_prototyping.ipynb
14:58:20.720 [debug] Controller selection change completed
14:58:20.730 [debug] Get Custom Env Variables, Class name = Sm, completed in 1ms, has a truthy return value, Arg 1: "~/starfish", Arg 2: "RunPythonCode"
14:58:20.730 [info] Starting Kernel (Python Path: /usr/bin/python, Unknown, 3.10.12) for '~/starfish/dexterity/gaussian_splatting/sam2_prototyping.ipynb' (disableUI=true)
14:58:20.744 [debug] Get Custom Env Variables, Class name = Sm, completed in 0ms, has a truthy return value, Arg 1: "~/starfish/dexterity/gaussian_splatting/sam2_prototyping.ipynb", Arg 2: "RunPythonCode"
14:58:20.794 [debug] Launching kernel .jvsc74a57bd0767d51c1340bd893661ea55ea3124f6de3c7a262a8b4abca0554b478b1e2ff90./usr/bin/python./usr/bin/python.-m#ipykernel_launcher for ~/starfish/dexterity/gaussian_splatting/sam2_prototyping.ipynb in //home/~/starfish/dexterity/gaussian_splatting with ports 9001, 9000, 9004, 9002, 9003
14:58:21.392 [warn] Failed to get activated env vars for /usr/bin/python in 663ms
14:58:21.395 [debug] Create ProcessService, Class name = Im (started execution), Arg 1: undefined
14:58:21.397 [warn] Failed to get activated env vars for /usr/bin/python in 653ms
14:58:21.399 [debug] Get Custom Env Variables, Class name = Sm, completed in 4ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunNonPythonCode", Arg 3: undefined
14:58:21.399 [debug] Create ProcessService, Class name = Im, completed in 4ms, has a truthy return value, Arg 1: undefined
14:58:21.404 [info] Process Execution: /usr/bin/python -c "import site;print("USER_BASE_VALUE");print(site.USER_BASE);print("USER_BASE_VALUE");"
14:58:21.441 [error] Unable to determine site packages path for python /usr/bin/python (Unknown)
14:58:21.441 [error] Unable to determine site packages path for python /usr/bin/python (Unknown)
14:58:21.442 [debug] Getting activated env variables, Class name = pd, completed in 712ms, has a truthy return value, Arg 1: "~/starfish", Arg 2: "/usr/bin/python", Arg 3: undefined
14:58:21.442 [debug] Getting activated env variables, Class name = pd, completed in 698ms, has a truthy return value, Arg 1: "~/starfish/dexterity/gaussian_splatting/sam2_prototyping.ipynb", Arg 2: "/usr/bin/python", Arg 3: undefined
14:58:21.447 [info] Process Execution: /usr/bin/python -m pip list
14:58:21.450 [info] Process Execution: /usr/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
14:58:21.457 [info] Process Execution: /usr/bin/python -m ipykernel_launcher --f=/home/~/.local/share/jupyter/runtime/kernel-v2-195878GfCndmy3uQc.json
    > cwd: //home/~/starfish/dexterity/gaussian_splatting
14:58:21.457 [debug] Kernel process 20116.
14:58:21.971 [debug] Controller startUsingPythonInterpreter:'.jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher' for view = 'jupyter-notebook' is no longer a valid
14:58:21.971 [debug] Controller startUsingPythonInterpreter:'.jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher (Interactive)' for view = 'interactive' is no longer a valid
14:58:21.971 [warn] Disposing old controller startUsingPythonInterpreter:'.jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher' for view = 'jupyter-notebook'
14:58:21.971 [debug] Disposing controller .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher associated with connection .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher 
14:58:21.976 [warn] Disposing old controller startUsingPythonInterpreter:'.jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher (Interactive)' for view = 'interactive'
14:58:21.976 [debug] Disposing controller .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher (Interactive) associated with connection .jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher 
14:58:21.979 [debug] Start refreshing Kernel Picker (1723733901979)
14:58:21.982 [debug] Controller startUsingPythonInterpreter:'.jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher' for view = 'jupyter-notebook' is no longer a valid
14:58:21.982 [debug] Controller startUsingPythonInterpreter:'.jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher (Interactive)' for view = 'interactive' is no longer a valid
14:58:21.983 [warn] Disposing old controller startUsingPythonInterpreter:'.jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher' for view = 'jupyter-notebook'
14:58:21.983 [debug] Disposing controller .jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher associated with connection .jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher 
14:58:21.983 [warn] Disposing old controller startUsingPythonInterpreter:'.jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher (Interactive)' for view = 'interactive'
14:58:21.983 [debug] Disposing controller .jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher (Interactive) associated with connection .jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher 
14:58:22.068 [warn] The following kernels use interpreters that are no longer valid or not recognized by Python extension, Kernels startUsingPythonInterpreter:'id=.jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher'(interpreterId='/bin/python3'),startUsingPythonInterpreter:'id=.jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher'(interpreterId='/usr/bin/python3') and valid interpreter ids include /home/~/miniconda3/bin/python, /home/~/miniconda3/envs/bdai/bin/python, /home/~/miniconda3/envs/cotracker/bin/python, /home/~/miniconda3/envs/docs_test/bin/python, /home/~/miniconda3/envs/gaussian-tracking/bin/python, /home/~/miniconda3/envs/hot3d/bin/python, /home/~/miniconda3/envs/jaxosqp/bin/python, /home/~/miniconda3/envs/mjpc/bin/python, /home/~/miniconda3/envs/nerfstudio/bin/python, /home/~/miniconda3/envs/sam2/bin/python, /home/~/miniconda3/envs/warp-test/bin/python, /bin/python, /usr/bin/python
14:58:22.068 [debug] Local Python connection deleted startUsingPythonInterpreter:'.jvsc74a57bd0916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1./bin/python3./bin/python3.-m#ipykernel_launcher: (interpreter id=/bin/python3)',startUsingPythonInterpreter:'.jvsc74a57bd031f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6./usr/bin/python3./usr/bin/python3.-m#ipykernel_launcher: (interpreter id=/usr/bin/python3)'
14:58:22.069 [debug] End refreshing Kernel Picker (1723733901979)
14:58:22.078 [debug] Kernel output 20116: To connect another client to this kernel, use:
--existing kernel-v2-195878GfCndmy3uQc.json
14:58:22.187 [debug] Waiting for Raw Session to be ready in postStartRawSession
14:58:22.187 [debug] Waiting for Raw session to be ready, status: connected
14:58:22.188 [debug] Waited for Raw session to be ready & got status: connected
14:58:22.188 [debug] Successfully waited for Raw Session to be ready in postStartRawSession
14:58:22.188 [debug] Kernel status is 'unknown' before requesting kernel info and after ready
14:58:22.188 [debug] Sending request for kernelInfo
14:58:22.199 [debug] Start refreshing Kernel Picker (1723733902199)
14:58:22.204 [warn] The following kernels use interpreters that are no longer valid or not recognized by Python extension, Kernels startUsingPythonInterpreter:'id=.jvsc74a57bd0e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a./bin/python./bin/python.-m#ipykernel_launcher'(interpreterId='/bin/python') and valid interpreter ids include /home/~/miniconda3/bin/python, /home/~/miniconda3/envs/bdai/bin/python, /home/~/miniconda3/envs/cotracker/bin/python, /home/~/miniconda3/envs/docs_test/bin/python, /home/~/miniconda3/envs/gaussian-tracking/bin/python, /home/~/miniconda3/envs/hot3d/bin/python, /home/~/miniconda3/envs/jaxosqp/bin/python, /home/~/miniconda3/envs/mjpc/bin/python, /home/~/miniconda3/envs/nerfstudio/bin/python, /home/~/miniconda3/envs/sam2/bin/python, /home/~/miniconda3/envs/warp-test/bin/python, /bin/python3, /usr/bin/python
14:58:22.204 [debug] Local Python connection deleted startUsingPythonInterpreter:'.jvsc74a57bd0e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a./bin/python./bin/python.-m#ipykernel_launcher: (interpreter id=/bin/python)'
14:58:22.204 [debug] End refreshing Kernel Picker (1723733902199)
14:58:22.212 [debug] Start refreshing Kernel Picker (1723733902212)
14:58:22.217 [warn] The following kernels use interpreters that are no longer valid or not recognized by Python extension, Kernels startUsingPythonInterpreter:'id=.jvsc74a57bd0767d51c1340bd893661ea55ea3124f6de3c7a262a8b4abca0554b478b1e2ff90./usr/bin/python./usr/bin/python.-m#ipykernel_launcher'(interpreterId='/usr/bin/python') and valid interpreter ids include /home/~/miniconda3/bin/python, /home/~/miniconda3/envs/bdai/bin/python, /home/~/miniconda3/envs/cotracker/bin/python, /home/~/miniconda3/envs/docs_test/bin/python, /home/~/miniconda3/envs/gaussian-tracking/bin/python, /home/~/miniconda3/envs/hot3d/bin/python, /home/~/miniconda3/envs/jaxosqp/bin/python, /home/~/miniconda3/envs/mjpc/bin/python, /home/~/miniconda3/envs/nerfstudio/bin/python, /home/~/miniconda3/envs/sam2/bin/python, /home/~/miniconda3/envs/warp-test/bin/python, /bin/python3, /usr/bin/python3
14:58:22.217 [debug] Local Python connection deleted startUsingPythonInterpreter:'.jvsc74a57bd0767d51c1340bd893661ea55ea3124f6de3c7a262a8b4abca0554b478b1e2ff90./usr/bin/python./usr/bin/python.-m#ipykernel_launcher: (interpreter id=/usr/bin/python)'
14:58:22.218 [debug] End refreshing Kernel Picker (1723733902212)
14:58:22.223 [debug] Successfully completed postStartRawSession after 1 attempt(s) in 35ms
14:58:22.263 [debug] Start refreshing Kernel Picker (1723733902263)
14:58:22.280 [debug] End refreshing Kernel Picker (1723733902263)
14:58:22.285 [debug] Start refreshing Kernel Picker (1723733902285)
14:58:22.291 [debug] End refreshing Kernel Picker (1723733902285)
14:58:22.457 [debug] Requesting Kernel info
14:58:22.461 [info] Kernel successfully started
14:58:22.514 [debug] No interpreter for Pylance for Notebook URI "/Interactive-1.interactive"
14:58:22.980 [debug] Interpreter removed /usr/bin/python3
14:58:22.984 [debug] Interpreter removed /bin/python3
14:58:29.933 [debug] Start refreshing Interpreter Kernel Picker
14:58:29.934 [debug] Start refreshing Kernel Picker (1723733909934)
14:58:29.956 [debug] Refreshed Environments
14:58:29.963 [debug] getDataDirsImpl, Class name = Mr (started execution), Arg 1: "~/starfish/dexterity/gaussian_splatting/sam2_prototyping.ipynb", Arg 2: "/usr/bin/python"
14:58:29.964 [debug] Get Custom Env Variables, Class name = Sm, completed in 1ms, has a truthy return value, Arg 1: undefined, Arg 2: "RunPythonCode"
14:58:29.964 [debug] Jupyter Paths : 
14:58:29.971 [debug] Get Custom Env Variables, Class name = Sm, completed in 1ms, has a truthy return value, Arg 1: "~/starfish/dexterity/gaussian_splatting/sam2_prototyping.ipynb", Arg 2: "RunPythonCode"
14:58:31.574 [debug] End refreshing Kernel Picker (1723733909934)
14:58:31.719 [warn] Failed to get activated env vars for /usr/bin/python in 1749ms
14:58:31.720 [error] Unable to determine site packages path for python /usr/bin/python (Unknown)
14:58:31.721 [debug] Getting activated env variables, Class name = pd, completed in 1751ms, has a truthy return value, Arg 1: "~/starfish/dexterity/gaussian_splatting/sam2_prototyping.ipynb", Arg 2: "/usr/bin/python", Arg 3: undefined
14:58:31.727 [info] Process Execution: /usr/bin/python /home/~/.vscode-server/extensions/ms-toolsai.jupyter-2024.7.0-linux-x64/pythonFiles/printJupyterDataDir.py
14:58:31.777 [debug] getDataDirsImpl, Class name = Mr, completed in 1814ms, has a truthy return value, Arg 1: "~/starfish/dexterity/gaussian_splatting/sam2_prototyping.ipynb", Arg 2: "/usr/bin/python", Return Value: <Uri:/home/~/.local/share/jupyter>, <Uri:/usr/local/share/jupyter>, <Uri:/usr/share/jupyter>

Coding Language and Runtime Version

Python v3.10.14

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Remote

DonJayamanne commented 4 weeks ago

Sorry you are running into this issue. What is the name of the interpreter that you have selected via Python: Select Interpreter

Please could you enable logging as follows:

pculbertson-bdai commented 4 weeks ago

Sure, here are the logs from the following steps:

Thanks so much for your help with this! Guessing this is user error / a weird edge case but struggling to find the cause / a good workaround.