Skip to content

Use the previously specified interpreter for a project regardless of environment #20644

Closed

Description

Original title: Visual Studio Code doesn't select the correct Python interpreter at launch

[Kubuntu 22.04]

Screenshot_20230203_125222

To fix it I have to manually select the first interpreter with the 'star' and 'Recommended' tag from the list, however it appears to be already selected (bottom right 3.10.6 ('.venv':venv)) after launch.

Steps to reproduce:

$ mkdir venvtest
$ cd venvtest
$ python3 -m venv .venv  
$ source .venv/bin/activate
$ pip install numpy
$ touch ptest.py
$ code .    

Python: Show Language Server Output:

[Info  - 1:44:07 PM] (21220) Pylance language server 2023.2.10 (pyright 01758105) starting
[Info  - 1:44:07 PM] (21220) Server root directory: /home/username/.vscode/extensions/ms-python.vscode-pylance-2023.2.10/dist
[Info  - 1:44:07 PM] (21220) Starting service instance "venvtest"
[Info  - 1:44:07 PM] (21220) No configuration file found.
[Info  - 1:44:07 PM] (21220) No pyproject.toml file found.
[Info  - 1:44:07 PM] (21220) Setting pythonPath for service "venvtest": "/home/username/Desktop/Tests/Python/venvtest/.venv"
[Warn  - 1:44:07 PM] (21220) stubPath /home/username/Desktop/Tests/Python/venvtest/typings is not a valid directory.
[Info  - 1:44:07 PM] (21220) Assuming Python platform Linux
[Info  - 1:44:07 PM] (21220) Searching for source files
[Info  - 1:44:07 PM] (21220) Found 1 source file
[Info  - 1:44:07 PM] (21220) Background analysis(1) root directory: /home/username/.vscode/extensions/ms-python.vscode-pylance-2023.2.10/dist
[Info  - 1:44:07 PM] (21220) Background analysis(1) started   

Edit (1): Python: Report Issue...

Type: Bug

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.6
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


languageServer: "Pylance"

VS Code version: Code 1.75.0 (e2816fe719a4026ffa1ee0189dc89bdfdbafb164, 2023-02-01T15:29:17.766Z)
OS version: Linux x64 5.15.0-58-generic
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (4 x 3600)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 1, 1, 1
Memory (System) 15.49GB (10.41GB free)
Process Argv . --crash-reporter-id defc98c6-3228-4e0f-9040-d3ced4598bef
Screen Reader no
VM 0%
DESKTOP_SESSION plasma
XDG_CURRENT_DESKTOP KDE
XDG_SESSION_DESKTOP KDE
XDG_SESSION_TYPE x11
Extensions (12)
Extension Author (truncated) Version
prettier-vscode esb 9.10.4
vscode-docker ms- 1.23.3
isort ms- 2022.8.0
python ms- 2023.2.0
vscode-pylance ms- 2023.2.10
jupyter ms- 2023.1.2000312134
jupyter-keymap ms- 1.0.0
jupyter-renderers ms- 1.0.14
vscode-jupyter-cell-tags ms- 0.1.6
vscode-jupyter-slideshow ms- 0.1.5
material-icon-theme PKi 4.23.1
LiveServer rit 5.7.9

(3 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vscaat:30438848
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
vsccc:30610678
pyindex848cf:30577861
nodejswelcome1cf:30587006
3biah626:30602489
f6dab269:30613381
pythonsymbol12cf:30657549
2i9eh265:30646982


Edit (2): Python Show Output

LSP Notebooks experiment is enabled
LSP Notebooks interactive window support is enabled
VS Code was launched from an activated environment: '.venv', selecting it as the interpreter for workspace.
> conda info --json
Python interpreter path: ./.venv/bin/python
> ./.venv/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
> .venv/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
> ~/miniconda3/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
> ~/miniconda3/envs/django-chapter-1/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
> ~/miniconda3/envs/python310/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
> /bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
> /usr/bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
Starting Pylance language server.
Python interpreter path: .venv/bin/python  

and these two lines are printed if I manually select recommended interpreter to fix the issue:

Python interpreter path: ./.venv/bin/python
> . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py

Activity

  1. brettcannon commented on Feb 3, 2023

    @brettcannon
    Member

    Can you please attach the output from the Python channel in the Output panel (or get all the details that the Python: report issue command pulls together as covered by https://aka.ms/pvsc-bug)?

  2. daeh commented on Feb 3, 2023

    @daeh

    I think I'm having a related issue. Since this last update, all of my projects open with the default interpreter. I can select the right interpreter, and that works for the session. But when VS code is restarted, it doesn't remember the correct interpreter and opens the project with the default. All of the interpreters (including the one that gets defaulted to) are conda environments.

    I'm using MacOS: 12.6.3
    VS code: 1.75.0
    Python extension: v2023.2.0

    • Python version (& distribution if applicable, e.g. Anaconda): 3.10.8
    • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
    • Value of the python.languageServer setting: Pylance

    Output of python extension when I open a project and set the interpreter to enviaa:

    LSP Notebooks experiment is enabled
    LSP Notebooks interactive window support is enabled
    > conda info --json
    VS Code was launched from an activated environment: 'lab', selecting it as the interpreter for workspace.
    Python interpreter path: ~/miniforge3/envs/lab/bin/python
    > /usr/bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > conda run -n lab --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > conda run -n lab --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > conda run -n ve_iaa_pytorch --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > conda run -n lab --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > ~/miniforge3/envs/lab/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/Applications/fsl/fslpython/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/Applications/fsl/fslpython/envs/fslpython/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniforge3/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniforge3/envs/enviaa/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /opt/homebrew/bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /opt/homebrew/bin/python3.11 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /opt/homebrew/bin/python3.9 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    Starting Pylance language server.
    Python interpreter path: ~/miniforge3/envs/enviaa/bin/python
    > conda run -n enviaa --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    

    Output when I reopen the project and it defaults to the lab interpreter:

    LSP Notebooks experiment is enabled
    LSP Notebooks interactive window support is enabled
    > conda info --json
    VS Code was launched from an activated environment: 'lab', selecting it as the interpreter for workspace.
    Python interpreter path: ~/miniforge3/envs/lab/bin/python
    > /usr/bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > conda run -n lab --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > conda run -n lab --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > conda run -n enviaa --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > conda run -n lab --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > ~/miniforge3/envs/lab/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/Applications/fsl/fslpython/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/Applications/fsl/fslpython/envs/fslpython/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniforge3/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniforge3/envs/enviaa/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /opt/homebrew/bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /opt/homebrew/bin/python3.11 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /opt/homebrew/bin/python3.9 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    Starting Pylance language server.
    

    Output of the Jupyter extension when VS code starts and defaults to lab rather than enviaa:

    Visual Studio Code (1.75.0, undefined, desktop)
    Jupyter Extension Version: 2023.1.2000312134.
    Python Extension Version: 2023.2.0.
    Workspace folder /Users/dae/***
    warn 15:27:53.711: Exception while attempting zmq : No native build was found for platform=darwin arch=arm64 runtime=electron abi=106 uv=1 armv=8 libc=glibc node=16.14.2 electron=19.1.9
        loaded from: /Users/dae/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/out/node_modules/zeromq
    
    info 15:27:53.770: Attempting to start a server because of preload conditions ...
    info 15:27:53.778: LSP Notebooks experiment is enabled
    info 15:27:53.778: Checking for server existence.
    info 15:27:53.979: Checking for server existence.
    info 15:27:53.979: Connecting to server
    info 15:27:53.980: Connecting server kernel http://localhost:9028/
    Connecting to Jupyter server at http://localhost:9028/
    info 15:27:53.980: Creating server with url : http://localhost:9028/
    info 15:27:53.990: Server started.
    info 15:27:53.991: Creating server with url : http://localhost:9028/
    error 15:27:54.011: Error fetching remote kernels: [FetchError: request to http://localhost:9028/api/kernels?1675456073993 failed, reason: connect ECONNREFUSED 127.0.0.1:9028
    	at ClientRequest.<anonymous> (/Users/dae/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/out/extension.node.js:2:1160163)
    	at ClientRequest.emit (node:events:526:28)
    	at Socket.socketErrorListener (node:_http_client:442:9)
    	at Socket.emit (node:events:526:28)
    	at emitErrorNT (node:internal/streams/destroy:157:8)
    	at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    	at process.processTicksAndRejections (node:internal/process/task_queues:83:21)]
    error 15:27:54.026: UniversalRemoteKernelFinder: Failed to get kernels without cache [FetchError: request to http://localhost:9028/api/kernels?1675456073993 failed, reason: connect ECONNREFUSED 127.0.0.1:9028
    	at ClientRequest.<anonymous> (/Users/dae/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/out/extension.node.js:2:1160163)
    	at ClientRequest.emit (node:events:526:28)
    	at Socket.socketErrorListener (node:_http_client:442:9)
    	at Socket.emit (node:events:526:28)
    	at emitErrorNT (node:internal/streams/destroy:157:8)
    	at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    	at process.processTicksAndRejections (node:internal/process/task_queues:83:21)]
    error 15:27:54.026: SessionManager:getKernelSpecs failure:  [Error: Poll (@jupyterlab/services:KernelSpecManager#specs) is disposed.
    	at e.dispose (/Users/dae/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/out/extension.node.js:2:172134)
    	at u.dispose (/Users/dae/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/out/extension.node.js:2:63778)
    	at Km.dispose (/Users/dae/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/out/extension.node.js:17:280038)
    	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    	at async Hm.listKernelsFromConnection (/Users/dae/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/out/extension.node.js:17:292430)]
    info 15:27:55.758: Process Execution: > ~/miniforge3/envs/enviaa/bin/python -m pip list
    > ~/miniforge3/envs/enviaa/bin/python -m pip list
    info 15:27:55.808: Process Execution: > ~/miniforge3/envs/lab/bin/python -c "import jupyter;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
    > ~/miniforge3/envs/lab/bin/python -c "import jupyter;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
    info 15:27:55.831: Process Execution: > ~/miniforge3/envs/lab/bin/python -c "import notebook;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
    > ~/miniforge3/envs/lab/bin/python -c "import notebook;print('6af208d0-cb9c-427f-b937-ff563e17efdf')"
    info 15:27:55.844: Process Execution: > ~/miniforge3/envs/lab/bin/python -m pip list
    > ~/miniforge3/envs/lab/bin/python -m pip list
    info 15:27:55.975: Process Execution: > ~/miniforge3/envs/lab/bin/python -m jupyter kernelspec --version
    > ~/miniforge3/envs/lab/bin/python -m jupyter kernelspec --version
    info 15:27:56.207: Connecting to server
    info 15:27:56.207: Launching server
    info 15:27:56.207: Starting Notebook
    info 15:27:56.210: Generating custom default config at /var/folders/fw/d09jz83j7n785m82v_22k35w0000gn/T/17707079-22f7-4d3d-8298-daf6f25803e0/jupyter_notebook_config.py
    Starting Jupyter from ~/miniforge3/envs/lab/bin/python with arguments --no-browser --notebook-dir="/Users/dae/***" --config=/var/folders/fw/d09jz83j7n785m82v_22k35w0000gn/T/17707079-22f7-4d3d-8298-daf6f25803e0/jupyter_notebook_config.py --NotebookApp.iopub_data_rate_limit=10000000000.0
    info 15:27:56.212: Process Execution: > ~/miniforge3/envs/lab/bin/python -m jupyter notebook --no-browser --notebook-dir="/Users/dae/***" --config=/var/folders/fw/d09jz83j7n785m82v_22k35w0000gn/T/17707079-22f7-4d3d-8298-daf6f25803e0/jupyter_notebook_config.py --NotebookApp.iopub_data_rate_limit=10000000000.0
    > ~/miniforge3/envs/lab/bin/python -m jupyter notebook --no-browser --notebook-dir="/Users/dae/c***" --config=/var/folders/fw/d09jz83j7n785m82v_22k35w0000gn/T/17707079-22f7-4d3d-8298-daf6f25803e0/jupyter_notebook_config.py --NotebookApp.iopub_data_rate_limit=10000000000.0
    /Users/dae/miniforge3/envs/lab/lib/python3.10/site-packages/traitlets/traitlets.py:2548: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use '/Users/dae/***' instead of '"/Users/dae/***"' if you require traitlets >=5.
      warn(
    [W 15:27:57.221 NotebookApp] Loading JupyterLab as a classic notebook (v6) extension.
    [C 15:27:57.221 NotebookApp] You must use Jupyter Server v1 to load JupyterLab as notebook extension. You have v2.1.0 installed.
        You can fix this by executing:
            pip install -U "jupyter-server<2.0.0"
    [I 15:27:57.223 NotebookApp] Serving notebooks from local directory: /Users/dae/***
    [I 15:27:57.223 NotebookApp] Jupyter Notebook 6.5.2 is running at:
    [I 15:27:57.223 NotebookApp] http://localhost:8888/?token=***
    [I 15:27:57.223 NotebookApp]  or http://127.0.0.1:8888/?token=***
    info 15:27:57.224: Process Execution: > ~/miniforge3/envs/lab/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/pythonFiles/vscode_datascience_helpers/getServerInfo.py
    > ~/miniforge3/envs/lab/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/pythonFiles/vscode_datascience_helpers/getServerInfo.py
    [I 15:27:57.223 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    info 15:27:57.225: Process Execution: > ~/miniforge3/envs/lab/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/pythonFiles/vscode_datascience_helpers/getServerInfo.py
    > ~/miniforge3/envs/lab/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/pythonFiles/vscode_datascience_helpers/getServerInfo.py
    [C 15:27:57.225 NotebookApp] 
        
        To access the notebook, open this file in a browser:
            file:///Users/dae/Library/Jupyter/runtime/nbserver-11203-open.html
        Or copy and paste one of these URLs:
            http://localhost:8888/?token=***
         or http://127.0.0.1:8888/?token=***
    info 15:27:57.226: Process Execution: > ~/miniforge3/envs/lab/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/pythonFiles/vscode_datascience_helpers/getServerInfo.py
    > ~/miniforge3/envs/lab/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.1.2000312134/pythonFiles/vscode_datascience_helpers/getServerInfo.py
    info 15:27:57.634: Connecting server kernel http://localhost:8888/
    info 15:27:57.634: Creating server with url : http://localhost:8888/
    info 15:27:57.637: Server started.
    
  3. brettcannon commented on Feb 3, 2023

    @brettcannon
    Member

    Output panel logs would still be appreciated.

  4. daeh commented on Feb 3, 2023

    @daeh

    Brett Cannon (@brettcannon) sorry, updated.

    the line
    VS Code was launched from an activated environment: 'lab', selecting it as the interpreter for workspace.
    makes me wonder if the python extension is overriding the workspace interpreter because I activate the lab env in my .zshrc

  5. maurczz commented on Feb 3, 2023

    @maurczz

    Dealing with the same exact issue right now, switching to the pre-release version of the extension seems to have fixed the issue.

  6. zebra-f commented on Feb 3, 2023

    @zebra-f
    Author
  7. daeh commented on Feb 3, 2023

    @daeh

    Updated.

    fyi it doesn't look like the output from the python extension was automatically included

  8. daeh commented on Feb 3, 2023

    @daeh

    Dealing with the same exact issue right now, switching to the pre-release version of the extension seems to have fixed the issue.

    Prerelease v2023.3.10341119 doesn't change the behavior for me

  9. zebra-f commented on Feb 4, 2023

    @zebra-f
    Author

    Update

    If I open Visual Studio Code by simply clicking on the icon instead from terminal it will load everything correctly (but only after I manually select recommended interpreter manually), built in terminal will also have activated virtual environment, here is the output:

    LSP Notebooks experiment is enabled
    LSP Notebooks interactive window support is enabled
    > conda info --json
    Python interpreter path: ./.venv/bin/python
    > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > ./.venv/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /usr/bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniconda3/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniconda3/envs/django-chapter-1/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniconda3/envs/python310/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    Starting Pylance language server.   
    

    To be clear what's going on:
    I open terminal
    I type in terminal

    source .venv/bin/activate   
    code .  
    

    I select manually recommended interpreter that fixes the issue
    I close Visual Studio Code
    I open Visual Studio Code by clicking on its icon (there is no issue)
    I close Visual Studio Code
    I open Visual Studio Code by clicking on its icon (there is no issue)
    I close Visual Studio Code (you get the point)
    I type in terminal again

    code .
    

    and now what's interesting, sometimes it will open without the issue, sometimes there will be a problem: Import "numpy" could not be resolved... but built in terminal will have activated (.venv) and most of the time it will have a problem and terminal won't have activated (.venv). (Edit: this behavior is not related to opening via the icon, It the same by running code . again right after selecting the correct interpreter and closing Visual Studio Code.)

    Also I noticed that when I select correct interpreter after opening via terminal that fixes the import problem, built in terminal won't have activated virtual environment (If I create a new terminal after selecting correct interpreter with the + sign, it will have activated environment).

    Mauricio Cruz (@maurczz) can you test it?

  10. karrtikr commented on Feb 4, 2023

    @karrtikr

    Rafal Zebrowski (@zebra-f) Sorry I don't quite understand the issue with your original bug report #20644 (comment). The Interpreter you intend to select ./.venv/bin/python is already selected by the extension (.venv means the same thing as ./.venv/bin/python). So I'm not sure what is there to fix.

  11. karrtikr commented on Feb 4, 2023

    @karrtikr

    makes me wonder if the python extension is overriding the workspace interpreter because I activate the lab env in my .zshrc

    Dae (@daeh) Actually yes, although we only intend to do it when lab is explicitly activated, which is not the case with you. Curious, why do you have .zshrc set to automatically activate lab when you intend to use a different environment (enviaa) as your interpreter?

    You temporarily fix the issue by reverting to previous version of the extension. Follow the prompts from "Extensions: Install Specific Version of Extension..." in the command palette:

    image

  12. zebra-f commented on Feb 4, 2023

    @zebra-f
    Author

    So I'm not sure what is there to fix.

    Kartik Raj (@karrtikr) me neither, but as I have said, there is a problem- Import "numpy" could not be resolved Pylance... and there is also that Coulndn't start client isort popup window.
    On the screenshot the first interpreter from the list won't have this issue (it's not selected, I have to do it manually). After selecting it (check my update), closing Visual Studio Code and reopening it again by clicking on the icon (or being lucky with code .- again look at update) it will have the first one from the list selected and there will be no issue, the second interpreter, highlighted on screenshot won't be even present.
    Also if I open Visual Studio Code for the first time (with the problem) and I select manually the first interpreter from the list to fix it I won't be able to select the second one again even thought it will be present.

    Here is the output when I get lucky reopening with code . method without the issue:

    LSP Notebooks experiment is enabled
    LSP Notebooks interactive window support is enabled
    VS Code was launched from an activated environment: '.venv', selecting it as the interpreter for workspace.
    > conda info --json
    Python interpreter path: ./.venv/bin/python
    > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/printEnvVariables.py
    > ./.venv/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniconda3/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniconda3/envs/django-chapter-1/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > ~/miniconda3/envs/python310/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > /usr/bin/python3 -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    > .venv/bin/python -I ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.2.0/pythonFiles/interpreterInfo.py
    Starting Pylance language server.    
    

    (.venv means the same thing as ./.venv/bin/python).

    well only ./.venv/bin/python appears to be working correctly.

  13. zebra-f commented on Feb 4, 2023

    @zebra-f
    Author

    https://streamable.com/bp75s5 sorry for the quality, but important parts should be visible.
    At 0:50 I was lucky (already mentioned in update).
    At 1:55 I'm trying to select the second interpreter.

  14. karrtikr commented on Feb 4, 2023

    @karrtikr

    Thanks, I understand the problem. Pylance and isort are using the wrong path to executable, I'll open the respective issues on their end.

  15. 30 remaining items

  16. karrtikr commented on Feb 9, 2023

    @karrtikr

    Fix should be out in the pre-release version of the extension, use the following to try it out:

    image

  17. daeh commented on Feb 9, 2023

    @daeh

    prerelease works great for me. Thank you Kartik Raj (@karrtikr) !

  18. ydmykr commented on Mar 8, 2023

    @ydmykr

    So I have a question. If I want a project to use a specified python interpreter, how do I set up or start the project? I don't seem to find a solution in this article.

  19. brettcannon commented on Mar 8, 2023

    @brettcannon
    Member

    ydmykr you can use "python.defaultInterpreterPath". If you have more questions, please ask in https://github.com/microsoft/vscode-python/discussions .

  20. ydmykr commented on Mar 9, 2023

    @ydmykr

    Brett Cannon (@brettcannon) However, according to the document about vscode-python, python.defaultInterpreterPath can only be used in USER settings. Is there any way to set it in the settings.json in .vscode folder?

    I want to be able to set the specified workspace instead of global. I can open a new issue if necessary, thanks alot.

  21. locked as resolved and limited conversation to collaborators on Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-environmentsFeatures relating to handling interpreter environmentsfeature-requestRequest for new features or functionalityneeds community feedbackAwaiting community feedbackverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions