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

Python doesn't fire environment changed when creating a new environment #21208

Closed
mpekurin opened this issue Apr 6, 2023 · 18 comments
Closed
Assignees
Labels
info-needed Issue requires more information from poster reports-wanted Looking for more people with the same issue triage-needed Needs assignment to the proper sub-team

Comments

@mpekurin
Copy link

mpekurin commented Apr 6, 2023

Environment data

  • Language Server version: 2023.4.10
  • OS and version: win32 x64 22621.1413
  • Python version (and distribution if applicable, e.g. Anaconda): 3.10.10
  • python.analysis.indexing: true
  • python.analysis.typeCheckingMode: off

Code Snippet

import pip
import github

Repro Steps

  1. Create an empty folder and open it in vscode.
  2. Run Python: Create Environment... -> Venv.
  3. After the environment is ready and python extension has selected it, install any package in the environment, e.g. pip install github.
  4. Create a new python file in the folder and add 2 imports into it: import pip and import github.

Expected behavior

Pylance uses the newly created environment.

Pressing F12 (Go To Definition) on pip opens pip's __init__.py from the venv. Pylance doesn't show Import "github" could not be resolved error.

Actual behavior

Pylance continues to use global environment, even though after creating the environment python extension shows We have selected the following environment: \path\to\venv notification and the status bar shows that the venv interpreter is selected.

Pressing F12 (Go To Definition) on pip opens pip's __init__.py from the global environment. Pylance shows Import "github" could not be resolved error because (according to logs) it still tries to find the package in the global environment.

To make pylance actually use the created environment, the user have to do one of the following:

  • Run Python: Restart Language Server.
  • Run Developer: Reload Window.
  • Reselect the interpreter used.
  • Change any pylance setting.

Logs

I've had to remove 'add' and 'change' evens between [Info - 4:28:17 PM] and [Info - 4:28:50 PM] because github limits body to 65536 characters. These events were triggered by Python: Create Environment....

(Client) New Client enabled
[Info  - 4:28:14 PM] (7940) Pylance language server 2023.4.10 (pyright d7616109) starting
[Info  - 4:28:14 PM] (7940) Server root directory: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist
[Info  - 4:28:14 PM] (7940) Starting service instance "issue"
[Info  - 4:28:14 PM] (7940) Auto-indent enabled
(7940) No configuration file found.
(7940) No pyproject.toml file found.
[Warn  - 4:28:14 PM] (7940) stubPath c:\Users\mpekurin\Downloads\issue\typings is not a valid directory.
(7940) Assuming Python platform Windows
[Info  - 4:28:14 PM] (7940) Search paths for c:\Users\mpekurin\Downloads\issue
[Info  - 4:28:14 PM] (7940)   c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib
[Info  - 4:28:14 PM] (7940)   c:\Users\mpekurin\Downloads\issue
[Info  - 4:28:14 PM] (7940)   c:\Users\mpekurin\Downloads\issue\typings
[Info  - 4:28:14 PM] (7940)   c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\...
[Info  - 4:28:14 PM] (7940)   c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs
[Info  - 4:28:14 PM] (7940)   c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs
[Info  - 4:28:14 PM] (7940)   c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib
[Info  - 4:28:14 PM] (7940)   c:\Users\mpekurin\AppData\Local\Programs\Python\Python310
[Info  - 4:28:14 PM] (7940)   c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages
[Info  - 4:28:14 PM] (7940) Adding fs watcher for library directories:
 C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs
C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib
C:\Users\mpekurin\AppData\Local\Programs\Python\Python310
C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib\site-packages
[Info  - 4:28:14 PM] (7940) Adding fs watcher for directories:
 c:\Users\mpekurin\Downloads\issue
(7940) Searching for source files
[Info  - 4:28:14 PM] (7940) No source files found.
[Info  - 4:28:15 PM] (7940) Background analysis(1) root directory: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist
[Info  - 4:28:15 PM] (7940) Background analysis(1) started
(7940) Background analysis message: setConfigOptions
(7940) Background analysis message: setImportResolver
(7940) Background analysis message: ensurePartialStubPackages
(7940) Background analysis message: setConfigOptions
(7940) Background analysis message: setTrackedFiles
(7940) Background analysis message: markAllFilesDirty
(7940) Background analysis message: analyze
[Info  - 4:28:17 PM] (7940) SourceFile: Received fs event 'add' for path 'c:\Users\mpekurin\Downloads\issue\.venv\Lib\site-packages\distutils-precedence.pth'
[Info  - 4:28:50 PM] (7940) SourceFile: Received fs event 'change' for path 'c:\Users\mpekurin\Downloads\issue\.venv\Lib\site-packages\aiohttp-3.8.1.dist-info\RECORD'
(7940) Background analysis message: setFileOpened
(7940) [FG] parsing: c:\Users\mpekurin\Downloads\issue\issue.py (106ms)
(7940) [FG] parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi [fs read 16ms] (423ms)
(7940) [FG] binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi (120ms)
(7940) [FG] binding: c:\Users\mpekurin\Downloads\issue\issue.py (0ms)
(7940) Background analysis message: analyze
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py ...
(7940) [BG(1)]   parsing: c:\Users\mpekurin\Downloads\issue\issue.py (196ms)
(7940) [BG(1)]   parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi [fs read 21ms] (350ms)
[Info  - 4:29:05 PM] (7940) SourceFile: Received fs event 'add' for path 'c:\Users\mpekurin\Downloads\issue\issue.py'
(7940) Searching for source files
[Info  - 4:29:05 PM] (7940) Found 1 source file
(7940) [BG(1)]   binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi (112ms)
(7940) [BG(1)]   binding: c:\Users\mpekurin\Downloads\issue\issue.py (0ms)
(7940) [BG(1)]   checking: c:\Users\mpekurin\Downloads\issue\issue.py (9ms)
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py (705ms)
(7940) Background analysis message: getSemanticTokens full
(7940) [BG(1)] getSemanticTokens full at c:\Users\mpekurin\Downloads\issue\issue.py (1ms)
(7940) Background analysis message: invalidateAndForceReanalysis
(7940) Background analysis message: setConfigOptions
(7940) Background analysis message: setTrackedFiles
(7940) Background analysis message: markAllFilesDirty
(7940) Background analysis message: analyze
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py ...
(7940) [BG(1)]   parsing: c:\Users\mpekurin\Downloads\issue\issue.py (123ms)
(7940) [BG(1)]   parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi [fs read 3ms] (134ms)
[Info  - 4:29:05 PM] (7940) Indexer background runner(2) root directory: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist (index)
[Info  - 4:29:05 PM] (7940) Indexing(2) started
(7940) [BG(1)]   binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi (80ms)
(7940) [BG(1)]   binding: c:\Users\mpekurin\Downloads\issue\issue.py (0ms)
(7940) [BG(1)]   checking: c:\Users\mpekurin\Downloads\issue\issue.py (24ms)
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py (363ms)
(7940) Background analysis message: resumeAnalysis
(7940) [BG(1)] indexing: c:\Users\mpekurin\Downloads\issue\issue.py (1ms)
(7940) Background analysis message: resumeAnalysis
(7940) [IDX(2)] scan packages c:\Users\mpekurin\Downloads\issue ...
(7940) [IDX(2)]   read stdlib indices (336ms)
(7940) Background analysis message: getSemanticTokens range
(7940) [BG(1)] getSemanticTokens range 0:0 - 0:0 at c:\Users\mpekurin\Downloads\issue\issue.py (0ms)
(7940) [FG] parsing: c:\Users\mpekurin\Downloads\issue\issue.py (104ms)
(7940) [FG] parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi [fs read 3ms] (172ms)
(7940) [FG] binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi (27ms)
(7940) [FG] binding: c:\Users\mpekurin\Downloads\issue\issue.py (0ms)
(7940) [IDX(2)] scan packages c:\Users\mpekurin\Downloads\issue (1552ms)
[Info  - 4:29:06 PM] (7940) scanned(2) 14 files over 1 exec env
(7940) IntelliCode model c:\Users\mpekurin\.vscode\extensions\visualstudioexptteam.vscodeintellicode-1.2.30\dist\bundledModels\python_intellisense-members-lstm-pylance
(7940) [IDX(2)] index packages c:\Users\mpekurin\Downloads\issue ...
(7940) [IDX(2)]   index execution environment c:\Users\mpekurin\Downloads\issue ...
(7940) [IDX(2)]     parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\__init__.pyi [fs read 1ms] (147ms)
(7940) [IDX(2)]     parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi [fs read 3ms] (112ms)
(7940) [IDX(2)]     binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\builtins.pyi (26ms)
(7940) [IDX(2)]     binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\__init__.pyi (1ms)
(7940) [IDX(2)]     indexing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\__init__.pyi ...
(7940) [IDX(2)]       parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\_deprecation_warning.pyi [fs read 3ms] (11ms)
(7940) [IDX(2)]       binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\_deprecation_warning.pyi (0ms)
(7940) [IDX(2)]       parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\depends.pyi [fs read 1ms] (2ms)
(7940) [IDX(2)]       binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\depends.pyi (0ms)
(7940) [IDX(2)]       parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\dist.pyi [fs read 0ms] (14ms)
(7940) [IDX(2)]       binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\dist.pyi (1ms)
(7940) [IDX(2)]       parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\extension.pyi [fs read 0ms] (11ms)
(7940) [IDX(2)]       binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\extension.pyi (0ms)
(7940) [IDX(2)]     indexing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stubs\setuptools\setuptools\__init__.pyi [found 12] (47ms)
(7940) [IDX(2)]     parsing: c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\xml\__init__.py [fs read 0ms] (4ms)
(7940) [IDX(2)]     binding: c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\xml\__init__.py (0ms)
(7940) [IDX(2)]     indexing: c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\xml\__init__.py [found 0] (1ms)
(7940) [IDX(2)]     parsing: c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages\pip\__init__.py [fs read 0ms] (0ms)
(7940) [IDX(2)]     binding: c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages\pip\__init__.py (0ms)
(7940) [IDX(2)]     indexing: c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages\pip\__init__.py [found 2] (17ms)
(7940) [IDX(2)]   index execution environment c:\Users\mpekurin\Downloads\issue [found 94 in 4 files] (380ms)
(7940) [IDX(2)] index packages c:\Users\mpekurin\Downloads\issue [found 94 in 1 exec envs] (396ms)
[Info  - 4:29:06 PM] (7940) indexed(2) 4 files over 1 exec env
[Info  - 4:29:06 PM] (7940) Indexing finished(2).
(7940) Loading ONNX runtime...
(7940) Loaded ONNX runtime. Creating IntelliCode session...
2023-04-06 16:29:08.595877 [I:onnxruntime:, inference_session.cc:263 operator()] Flush-to-zero and denormal-as-zero are off
2023-04-06 16:29:08.597049 [I:onnxruntime:, inference_session.cc:271 ConstructorCommon] Creating and using per session threadpools since use_per_session_threads_ is true
2023-04-06 16:29:08.597738 [I:onnxruntime:, inference_session.cc:292 ConstructorCommon] Dynamic block base set to 0
2023-04-06 16:29:08.681408 [I:onnxruntime:, inference_session.cc:1222 Initialize] Initializing session.
2023-04-06 16:29:08.681598 [I:onnxruntime:, inference_session.cc:1259 Initialize] Adding default CPU execution provider.
2023-04-06 16:29:08.687679 [I:onnxruntime:, reshape_fusion.cc:42 ApplyImpl] Total fused reshape node count: 0
2023-04-06 16:29:08.689250 [I:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing NodeArg 'rnn/transpose'. It is no longer used by any node.
2023-04-06 16:29:08.689428 [I:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing NodeArg 'Gather_out0'. It is no longer used by any node.
2023-04-06 16:29:08.689573 [I:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing NodeArg 'Transpose_out0'. It is no longer used by any node.
2023-04-06 16:29:08.690099 [I:onnxruntime:, reshape_fusion.cc:42 ApplyImpl] Total fused reshape node count: 0
2023-04-06 16:29:08.710533 [V:onnxruntime:, session_state.cc:1010 VerifyEachNodeIsAssignedToAnEp] Node placements
2023-04-06 16:29:08.710725 [V:onnxruntime:, session_state.cc:1013 VerifyEachNodeIsAssignedToAnEp]  All nodes placed on [CPUExecutionProvider]. Number of nodes: 59
2023-04-06 16:29:08.711195 [V:onnxruntime:, session_state.cc:66 CreateGraphInfo] SaveMLValueNameIndexMapping
2023-04-06 16:29:08.711358 [V:onnxruntime:, session_state.cc:112 CreateGraphInfo] Done saving OrtValue mappings.
2023-04-06 16:29:08.711881 [I:onnxruntime:, session_state_utils.cc:199 SaveInitializedTensors] Saving initialized tensors.
2023-04-06 16:29:08.795936 [I:onnxruntime:, session_state_utils.cc:342 SaveInitializedTensors] Done saving initialized tensors
2023-04-06 16:29:08.797329 [I:onnxruntime:, inference_session.cc:1488 Initialize] Session successfully initialized.
(7940) Created IntelliCode session.
(7940) Initialize deeplearning succeeded
(7940) Background analysis message: setFileOpened
(7940) Background analysis message: markFilesDirty
(7940) [FG] parsing: c:\Users\mpekurin\Downloads\issue\issue.py (15ms)
(7940) [FG] binding: c:\Users\mpekurin\Downloads\issue\issue.py (1ms)
(7940) Background analysis message: analyze
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py ...
(7940) [BG(1)]   parsing: c:\Users\mpekurin\Downloads\issue\issue.py (15ms)
(7940) [BG(1)]   binding: c:\Users\mpekurin\Downloads\issue\issue.py (0ms)
(7940) [BG(1)]   checking: c:\Users\mpekurin\Downloads\issue\issue.py ...
(7940) [BG(1)]     parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\typing.pyi [fs read 1ms] (22ms)
(7940) [BG(1)]     binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\typing.pyi (11ms)
(7940) [BG(1)]     parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\typing_extensions.pyi [fs read 1ms] (6ms)
(7940) [BG(1)]     binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\typing_extensions.pyi (3ms)
(7940) [BG(1)]     parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\_typeshed\__init__.pyi [fs read 1ms] (38ms)
(7940) [BG(1)]     binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\_typeshed\__init__.pyi (8ms)
(7940) [BG(1)]     parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\types.pyi [fs read 1ms] (57ms)
(7940) [BG(1)]     binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\types.pyi (10ms)
(7940) [BG(1)]     parsing: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\abc.pyi [fs read 0ms] (1ms)
(7940) [BG(1)]     binding: c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib\abc.pyi (0ms)
(7940) [BG(1)]     parsing: c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages\pip\__init__.py [fs read 0ms] (4ms)
(7940) [BG(1)]     binding: c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages\pip\__init__.py (1ms)
(7940) [BG(1)]   checking: c:\Users\mpekurin\Downloads\issue\issue.py (235ms)
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py (251ms)
(7940) Background analysis message: resumeAnalysis
(7940) [BG(1)] indexing: c:\Users\mpekurin\Downloads\issue\issue.py [found 0] (0ms)
(7940) Indexing Done: c:\Users\mpekurin\Downloads\issue\issue.py
(7940) Background analysis message: getSemanticTokens delta
(7940) [BG(1)] getSemanticTokens delta previousResultId:1680787744244 at c:\Users\mpekurin\Downloads\issue\issue.py (1ms)
(7940) Background analysis message: setFileOpened
(7940) Background analysis message: markFilesDirty
(7940) [FG] parsing: c:\Users\mpekurin\Downloads\issue\issue.py (2ms)
[Info  - 4:29:22 PM] (7940) Could not import 'github' in file 'c:\Users\mpekurin\Downloads\issue\issue.py'
[Info  - 4:29:22 PM] (7940)   Looking in stubPath 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:22 PM] (7940)   Looking in root directory of execution environment 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:22 PM] (7940)   Finding python search paths
[Info  - 4:29:22 PM] (7940)   Executing interpreter: 'python'
[Info  - 4:29:22 PM] (7940)   Skipping 'C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\python310.zip' because it is not a valid directory
[Info  - 4:29:22 PM] (7940)   Received 4 paths from interpreter
[Info  - 4:29:22 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs
[Info  - 4:29:22 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib
[Info  - 4:29:22 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310
[Info  - 4:29:22 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib\site-packages
[Info  - 4:29:22 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:22 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:22 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:22 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:22 PM] (7940)   Looking in bundled stubs path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:22 PM] (7940)   Looking for typeshed stdlib path
[Info  - 4:29:22 PM] (7940)   Looking for typeshed stdlib path
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib'
[Info  - 4:29:22 PM] (7940)   Typeshed path not found
[Info  - 4:29:22 PM] (7940)   Looking for typeshed third-party path
[Info  - 4:29:22 PM] (7940)   Looking for typeshed stubs path
[Info  - 4:29:22 PM] (7940)   Typeshed path not found
(7940) [FG] binding: c:\Users\mpekurin\Downloads\issue\issue.py (0ms)
(7940) Background analysis message: analyze
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py ...
(7940) [BG(1)]   parsing: c:\Users\mpekurin\Downloads\issue\issue.py (1ms)
[Info  - 4:29:22 PM] (7940) Could not import 'github' in file 'c:\Users\mpekurin\Downloads\issue\issue.py'
[Info  - 4:29:22 PM] (7940)   Looking in stubPath 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:22 PM] (7940)   Looking in root directory of execution environment 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:22 PM] (7940)   Finding python search paths
[Info  - 4:29:22 PM] (7940)   Executing interpreter: 'python'
[Info  - 4:29:22 PM] (7940)   Skipping 'C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\python310.zip' because it is not a valid directory
[Info  - 4:29:22 PM] (7940)   Received 4 paths from interpreter
[Info  - 4:29:22 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs
[Info  - 4:29:22 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib
[Info  - 4:29:22 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310
[Info  - 4:29:22 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib\site-packages
[Info  - 4:29:22 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:22 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:22 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:22 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:22 PM] (7940)   Looking in bundled stubs path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:22 PM] (7940)   Looking for typeshed stdlib path
[Info  - 4:29:22 PM] (7940)   Looking for typeshed stdlib path
[Info  - 4:29:22 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib'
[Info  - 4:29:22 PM] (7940)   Typeshed path not found
[Info  - 4:29:22 PM] (7940)   Looking for typeshed third-party path
[Info  - 4:29:22 PM] (7940)   Looking for typeshed stubs path
[Info  - 4:29:22 PM] (7940)   Typeshed path not found
(7940) [BG(1)]   binding: c:\Users\mpekurin\Downloads\issue\issue.py (1ms)
(7940) [BG(1)]   checking: c:\Users\mpekurin\Downloads\issue\issue.py (24ms)
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py (27ms)
(7940) Background analysis message: getDiagnosticsForRange
(7940) Background analysis message: resumeAnalysis
(7940) [BG(1)] indexing: c:\Users\mpekurin\Downloads\issue\issue.py [found 0] (0ms)
(7940) Indexing Done: c:\Users\mpekurin\Downloads\issue\issue.py
(7940) Background analysis message: getDiagnosticsForRange
(7940) Background analysis message: getDiagnosticsForRange
(7940) Background analysis message: getDiagnosticsForRange
(7940) Background analysis message: getSemanticTokens delta
(7940) [BG(1)] getSemanticTokens delta previousResultId:1680787755158 at c:\Users\mpekurin\Downloads\issue\issue.py (1ms)
(7940) Background analysis message: setFileOpened
(7940) Background analysis message: markFilesDirty
(7940) [FG] parsing: c:\Users\mpekurin\Downloads\issue\issue.py (0ms)
[Info  - 4:29:34 PM] (7940) Could not import 'github' in file 'c:\Users\mpekurin\Downloads\issue\issue.py'
[Info  - 4:29:34 PM] (7940)   Looking in stubPath 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:34 PM] (7940)   Looking in root directory of execution environment 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:34 PM] (7940)   Finding python search paths
[Info  - 4:29:34 PM] (7940)   Executing interpreter: 'python'
[Info  - 4:29:34 PM] (7940)   Skipping 'C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\python310.zip' because it is not a valid directory
[Info  - 4:29:34 PM] (7940)   Received 4 paths from interpreter
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib\site-packages
[Info  - 4:29:34 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:34 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:34 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:34 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:34 PM] (7940)   Looking in bundled stubs path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:34 PM] (7940)   Looking for typeshed stdlib path
[Info  - 4:29:34 PM] (7940)   Looking for typeshed stdlib path
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib'
[Info  - 4:29:34 PM] (7940)   Typeshed path not found
[Info  - 4:29:34 PM] (7940)   Looking for typeshed third-party path
[Info  - 4:29:34 PM] (7940)   Looking for typeshed stubs path
[Info  - 4:29:34 PM] (7940)   Typeshed path not found
(7940) [FG] binding: c:\Users\mpekurin\Downloads\issue\issue.py (1ms)
(7940) Background analysis message: analyze
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py ...
(7940) [BG(1)]   parsing: c:\Users\mpekurin\Downloads\issue\issue.py (2ms)
[Info  - 4:29:34 PM] (7940) Could not import 'github' in file 'c:\Users\mpekurin\Downloads\issue\issue.py'
[Info  - 4:29:34 PM] (7940)   Looking in stubPath 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\Downloads\issue\typings'
[Info  - 4:29:34 PM] (7940)   Looking in root directory of execution environment 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\Downloads\issue'
[Info  - 4:29:34 PM] (7940)   Finding python search paths
[Info  - 4:29:34 PM] (7940)   Executing interpreter: 'python'
[Info  - 4:29:34 PM] (7940)   Skipping 'C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\python310.zip' because it is not a valid directory
[Info  - 4:29:34 PM] (7940)   Received 4 paths from interpreter
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib\site-packages
[Info  - 4:29:34 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs'
[Info  - 4:29:34 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib'
[Info  - 4:29:34 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310'
[Info  - 4:29:34 PM] (7940)   Looking in python search path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\AppData\Local\Programs\Python\Python310\Lib\site-packages'
[Info  - 4:29:34 PM] (7940)   Looking in bundled stubs path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve stub package using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\bundled\stubs'
[Info  - 4:29:34 PM] (7940)   Looking for typeshed stdlib path
[Info  - 4:29:34 PM] (7940)   Looking for typeshed stdlib path
[Info  - 4:29:34 PM] (7940)   Attempting to resolve using root path 'c:\Users\mpekurin\.vscode\extensions\ms-python.vscode-pylance-2023.4.10\dist\typeshed-fallback\stdlib'
[Info  - 4:29:34 PM] (7940)   Typeshed path not found
[Info  - 4:29:34 PM] (7940)   Looking for typeshed third-party path
[Info  - 4:29:34 PM] (7940)   Looking for typeshed stubs path
[Info  - 4:29:34 PM] (7940)   Typeshed path not found
(7940) [BG(1)]   binding: c:\Users\mpekurin\Downloads\issue\issue.py (0ms)
(7940) [BG(1)]   checking: c:\Users\mpekurin\Downloads\issue\issue.py (24ms)
(7940) [BG(1)] analyzing: c:\Users\mpekurin\Downloads\issue\issue.py (29ms)
(7940) Background analysis message: resumeAnalysis
(7940) [BG(1)] indexing: c:\Users\mpekurin\Downloads\issue\issue.py [found 0] (0ms)
(7940) Indexing Done: c:\Users\mpekurin\Downloads\issue\issue.py
[Info  - 4:29:34 PM] (7940) SourceFile: Received fs event 'change' for path 'c:\Users\mpekurin\Downloads\issue\issue.py'
(7940) Background analysis message: markFilesDirty
(7940) Background analysis message: analyze
(7940) Background analysis message: getDiagnosticsForRange
(7940) Background analysis message: getDiagnosticsForRange
(7940) Background analysis message: getSemanticTokens delta
(7940) [BG(1)] getSemanticTokens delta previousResultId:1680787763034 at c:\Users\mpekurin\Downloads\issue\issue.py (1ms)

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Apr 6, 2023
@rchiodo
Copy link

rchiodo commented Apr 6, 2023

Thanks for the issue.

What is the path to your venv?

In order for Pylance to pick up changes to it, it has to be in the workspace itself. We watch for file changes in the workspace, but we can't watch for changes elsewhere (VS code provides us with the file watchers).

This works for me as long as the venv is in the workspace.

These sort of events should be in the log:

[Info  - 9:36:21 AM] (30692) SourceFile: Received fs event 'change' for path 'd:\Source\Testing\Testing_Newenv\.venv\Lib\site-packages\pygame\docs\generated\_static\pygame_tiny.png'

Looking at your log, it seems like the python path was never changed. It keeps showing this:

[Info  - 4:29:34 PM] (7940)   Finding python search paths
[Info  - 4:29:34 PM] (7940)   Executing interpreter: 'python'
[Info  - 4:29:34 PM] (7940)   Skipping 'C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\python310.zip' because it is not a valid directory
[Info  - 4:29:34 PM] (7940)   Received 4 paths from interpreter
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\DLLs
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310
[Info  - 4:29:34 PM] (7940)     C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\lib\site-packages

Whereas after I set the interpreter to the new virtual environment, I get something like so:

[Info  - 9:33:56 AM] (30692)   Finding python search paths
[Info  - 9:33:56 AM] (30692)   Executing interpreter: 'd:\Source\Testing\Testing_Newenv\.venv\Scripts\python.exe'
[Info  - 9:33:56 AM] (30692)   Skipping 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\python310.zip' because it is not a valid directory
[Info  - 9:33:56 AM] (30692)   Received 5 paths from interpreter
[Info  - 9:33:56 AM] (30692)     C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\DLLs
[Info  - 9:33:56 AM] (30692)     C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib
[Info  - 9:33:56 AM] (30692)     C:\Users\aku91\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0
[Info  - 9:33:56 AM] (30692)     d:\Source\Testing\Testing_Newenv\.venv
[Info  - 9:33:56 AM] (30692)     d:\Source\Testing\Testing_Newenv\.venv\lib\site-packages

Do you perhaps have a pythonPath set in a pyrightconfig.json or a settings file?

If you look at the output for the Python extension, it should list the changing of the interpreter. Mine shows this:

Python interpreter path: .\.venv\Scripts\python.exe

@rchiodo rchiodo removed the triage-needed Needs assignment to the proper sub-team label Apr 6, 2023
@mpekurin
Copy link
Author

mpekurin commented Apr 7, 2023

What is the path to your venv?

The venv (c:\Users\mpekurin\Downloads\issue\.venv) was created in the opened workspace (c:\Users\mpekurin\Downloads\issue). Python: Create Environment... doesn't allow to set a path of venv it creates anyway.

In order for Pylance to pick up changes to it, it has to be in the workspace itself. We watch for file changes in the workspace, but we can't watch for changes elsewhere (VS code provides us with the file watchers).

This works for me as long as the venv is in the workspace.

These sort of events should be in the log

Yes, there was a bunch of 'add' and 'change' events triggered by the creation of the environment in the original log.

Looking at your log, it seems like the python path was never changed.

Yep. The path wasn't changed according to Python Language Server output but it was changed according to Python output:

Python interpreter path: .\.venv\Scripts\python.exe

If I perform anything described in the Actual behaviour, the server starts using the virtual environment (as expected):

[Info  - 1:31:30 PM] (12332) Setting pythonPath for service "issue": "c:\Users\mpekurin\Downloads\issue\.venv\Scripts\python.exe"

Whereas after I set the interpreter to the new virtual environment, I get something like so

Selecting an environment manually works as expected. The issue described happens only when a user creates an environment via Python: Create Environment... and the extension automatically selects it afterwards (shows We have selected the following environment message). As I understand, in this case features not related to the server (running, debugging, creating new terminals) work with the virtual environment while features that depend on the server (IntelliSense, code navigation) continue to think that the global interpreter is used.

Do you perhaps have a pythonPath set in a pyrightconfig.json or a settings file?

No. Moreover, I've tested the case on another computer that has never had neither vscode nor python installed and its behaviour has been exactly the same.

@rchiodo
Copy link

rchiodo commented Apr 7, 2023

Okay thanks. This sounds like a bug in the Python extension. It may be forgetting to fire an event that indicates the interpreter changed.

I don't reproduce this issue myself, but you might want to double check what your Python extension version is.

I have the following:

Python extension: 2022.20.2

I also tried this one:

Python extension: 2023.1.10091012

Both of those worked for me.

@rchiodo rchiodo transferred this issue from microsoft/pylance-release Apr 7, 2023
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Apr 7, 2023
@rchiodo rchiodo changed the title Pylance won't switch to using a newly created venv Python doesn't fire environment changed when creating a new environment Apr 7, 2023
@mpekurin
Copy link
Author

mpekurin commented Apr 10, 2023

Python extension is 2023.6.0. I'll check if the issue persists in older versions.

@karrtikr
Copy link

Thanks for the bug report! We investigate issues in order based on priority and severity, which includes the impact it has on your ability to use the extension to do productive work, and the number of people affected. If other users come forward and leave a comment demonstrating they are seeing/reproducing the problem then we will raise this issue's priority. Thanks for understanding and the patience!

@karrtikr
Copy link

karrtikr commented May 9, 2023

Yep. The path wasn't changed according to Python Language Server output but it was changed according to Python output:

Given the path is changed event should be fired. Perhaps language server component doesn't subscribe to it correctly.

Reassigning to LS as things look good from environment side, we've to make sure pythonPath is correctly which probably happens here:

@karthiknadig
Copy link
Member

@debonte Can you look into this or assign someone to investigate this?

@debonte debonte transferred this issue from microsoft/vscode-python May 9, 2023
@rchiodo
Copy link

rchiodo commented May 9, 2023

Given the path is changed event should be fired. Perhaps language server component doesn't subscribe to it correctly.

We don't subscribe to an event. The Python Extension just sends a configuration change message itself when a creating a new environment. That code is here:

https://github.com/microsoft/vscode-python/blob/main/src/client/activation/node/languageServerProxy.ts#L176

Is it possible the 'Create New Environment' is not firing the event?
https://github.com/microsoft/vscode-python/blob/main/src/client/common/interpreterPathService.ts#L106

I still think this is a python core extension issue. We are not getting the config change message.

@rchiodo
Copy link

rchiodo commented May 9, 2023

I can repro the issue if I delete the folder and start over again. The config message won't be sent because the internal store says the path is the same and it doesn't fire the change event. That's in the interpreterPathService.

Similarly, if I set pylanceLspClientEnabled to true, we never get a onDidChangeActiveEnvironmentPath event from the Python core extension (in the same situation with a folder that was used and then deleted).

I think there's an issue with the fetching of the python path from storage. Storage should be cleared if the value is invalid.

That doesn't sound like the user's problem though. I can only repro this issue if the folder was already opened at some point and then deleted.

@rchiodo rchiodo transferred this issue from microsoft/pylance-release May 9, 2023
@karthiknadig karthiknadig assigned karrtikr and karthiknadig and unassigned karrtikr May 9, 2023
@karthiknadig karthiknadig added the reports-wanted Looking for more people with the same issue label May 9, 2023
@karthiknadig karthiknadig added the investigating We are looking into the cause of the issue label May 9, 2023
@karrtikr
Copy link

karrtikr commented May 9, 2023

@mpekurin We added more logs, and pushed a new-build, can you try getting the logs again?

  • Install the pre-release version of the extension?

image

  • After that, please provide the logs as mentioned in the issue template. Set python.logging.level to debug in User settings, reload window, then perform the Repro Steps before providing the logs.
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

@github-actions github-actions bot added the info-needed Issue requires more information from poster label May 9, 2023
@mpekurin
Copy link
Author

@karrtikr sure

Python log, v2023.9.11292255
2023-05-10 12:00:19.069 [info] Experiment 'pythonaa' is active
2023-05-10 12:00:19.069 [info] Experiment 'pythonPromptNewFormatterExt' is active
2023-05-10 12:00:19.069 [info] Experiment 'pythonPromptNewToolsExt' is active
2023-05-10 12:00:19.069 [info] Experiment 'pythonSurveyNotification' is active
2023-05-10 12:00:19.113 [info] Test server listening.
2023-05-10 12:00:19.147 [warning] Retry failed, storage update failed for key PYTHON_WORKSPACE_STORAGE_KEYS
2023-05-10 12:00:19.147 [warning] Retry failed, storage update failed for key PYTHON_WORKSPACE_STORAGE_KEYS
2023-05-10 12:00:19.147 [warning] Retry failed, storage update failed for key PYTHON_WORKSPACE_STORAGE_KEYS
2023-05-10 12:00:19.151 [warning] Identifier for virt-virtualenv failed to identify c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'c:\Users\mpekurin\Downloads\test\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts'
}
2023-05-10 12:00:19.170 [info] > .\.venv\Scripts\python.exe -I ~\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\interpreterInfo.py
2023-05-10 12:00:19.170 [warning] Identifier for virt-virtualenv failed to identify c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'c:\Users\mpekurin\Downloads\test\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts'
}
2023-05-10 12:00:19.170 [warning] Identifier for virt-virtualenv failed to identify c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'c:\Users\mpekurin\Downloads\test\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts'
}
2023-05-10 12:00:19.204 [error] [Error: Command failed: c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe -I c:\Users\mpekurin\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\get_output_via_markers.py c:\Users\mpekurin\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\interpreterInfo.py
���⥬� �� 㤠���� ���� 㪠����� ����.

	at ChildProcess.exithandler (node:child_process:409:12)
	at ChildProcess.emit (node:events:513:28)
	at maybeClose (node:internal/child_process:1112:16)
	at ChildProcess._handle.onexit (node:internal/child_process:304:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts\\python.exe -I c:\\Users\\mpekurin\\.vscode\\extensions\\ms-python.python-2023.9.11292255\\pythonFiles\\get_output_via_markers.py c:\\Users\\mpekurin\\.vscode\\extensions\\ms-python.python-2023.9.11292255\\pythonFiles\\interpreterInfo.py'
}
2023-05-10 12:00:19.687 [info] > conda info --json
2023-05-10 12:00:19.760 [warning] Identifier for virt-virtualenv failed to identify c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'c:\Users\mpekurin\Downloads\test\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts'
}
2023-05-10 12:00:19.771 [info] > ~\AppData\Local\Programs\Python\Python310\python.exe -I ~\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\interpreterInfo.py
2023-05-10 12:00:21.214 [info] > .\.venv\Scripts\python.exe -I ~\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\interpreterInfo.py
2023-05-10 12:00:21.255 [error] [Error: Command failed: c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe -I c:\Users\mpekurin\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\get_output_via_markers.py c:\Users\mpekurin\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\interpreterInfo.py
���⥬� �� 㤠���� ���� 㪠����� ����.

	at ChildProcess.exithandler (node:child_process:409:12)
	at ChildProcess.emit (node:events:513:28)
	at maybeClose (node:internal/child_process:1112:16)
	at ChildProcess._handle.onexit (node:internal/child_process:304:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts\\python.exe -I c:\\Users\\mpekurin\\.vscode\\extensions\\ms-python.python-2023.9.11292255\\pythonFiles\\get_output_via_markers.py c:\\Users\\mpekurin\\.vscode\\extensions\\ms-python.python-2023.9.11292255\\pythonFiles\\interpreterInfo.py'
}
2023-05-10 12:00:21.270 [warning] Identifier for virt-virtualenv failed to identify c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'c:\Users\mpekurin\Downloads\test\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts'
}
2023-05-10 12:00:21.917 [info] Running Env creation script:  [
  'C:\\Users\\mpekurin\\AppData\\Local\\Programs\\Python\\Python310\\python.exe',
  'c:\\Users\\mpekurin\\.vscode\\extensions\\ms-python.python-2023.9.11292255\\pythonFiles\\create_venv.py',
  '--git-ignore'
]
2023-05-10 12:00:22.168 [info] Running: C:\Users\mpekurin\AppData\Local\Programs\Python\Python310\python.exe -m venv .venv

2023-05-10 12:00:22.252 [info] Starting Pylance language server.
2023-05-10 12:00:22.266 [warning] Identifier for virt-virtualenv failed to identify c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'c:\Users\mpekurin\Downloads\test\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts'
}
2023-05-10 12:00:22.269 [warning] Identifier for virt-virtualenv failed to identify c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'c:\Users\mpekurin\Downloads\test\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts'
}
2023-05-10 12:00:22.279 [info] > .\.venv\Scripts\python.exe -c "import sys;print(sys.executable)"
2023-05-10 12:00:22.357 [warning] Identifier for virt-virtualenv failed to identify c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'c:\Users\mpekurin\Downloads\test\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts'
}
2023-05-10 12:00:22.357 [warning] Identifier for virt-virtualenv failed to identify c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe [Error: ENOENT: no such file or directory, scandir 'c:\Users\mpekurin\Downloads\test\.venv\Scripts'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\Users\\mpekurin\\Downloads\\test\\.venv\\Scripts'
}
2023-05-10 12:00:23.549 [info] > .\.venv\Scripts\python.exe -I ~\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2023.9.11292255\pythonFiles\interpreterInfo.py
2023-05-10 12:00:36.181 [info] CREATED_VENV:c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe
Creating: c:\Users\mpekurin\Downloads\test\.venv\.gitignore

2023-05-10 12:00:36.181 [info] CREATE_VENV.UPGRADING_PIP
Running: c:\Users\mpekurin\Downloads\test\.venv\Scripts\python.exe -m pip install --upgrade pip

2023-05-10 12:00:37.289 [info] Requirement already satisfied: pip in c:\users\mpekurin\downloads\test\.venv\lib\site-packages (22.3.1)

2023-05-10 12:00:37.523 [info] Collecting pip

2023-05-10 12:00:37.532 [info]   Using cached pip-23.1.2-py3-none-any.whl (2.1 MB)

2023-05-10 12:00:37.638 [info] Installing collected packages: pip

2023-05-10 12:00:37.639 [info]   Attempting uninstall: pip

2023-05-10 12:00:37.640 [info]     Found existing installation: pip 22.3.1

2023-05-10 12:00:38.937 [info]     Uninstalling pip-22.3.1:

2023-05-10 12:00:38.987 [info]       Successfully uninstalled pip-22.3.1

2023-05-10 12:00:45.986 [info] Successfully installed pip-23.1.2

2023-05-10 12:00:46.119 [info] CREATE_VENV.UPGRADED_PIP

2023-05-10 12:00:52.270 [info] Send text to terminal: & c:/Users/mpekurin/Downloads/test/.venv/Scripts/Activate.ps1
2023-05-10 12:01:08.443 [info] Python interpreter path: .\.venv\Scripts\python.exe
2023-05-10 12:01:10.656 [info] > ./.venv/Scripts/activate.bat && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.9.11292255/pythonFiles/printEnvVariables.py
2023-05-10 12:01:10.656 [info] shell: commandPrompt

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label May 10, 2023
@mpekurin
Copy link
Author

mpekurin commented May 10, 2023

I can only repro this issue if the folder was already opened at some point and then deleted.

I didn't notice this before but this is true. If I do the repro steps in a folder that had never ever been opened in vscode before everything works as expected.

@karrtikr
Copy link

I think you missed to set "Set python.logging.level to debug in User settings" as asked earlier, maybe you didn't reload?

I didn't notice this before but this is true. If I do the repro steps in a folder that had never ever been opened in vscode before everything works as expected.

I see, in that case try Python: Clear cache and reload command after providing the logs.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label May 10, 2023
@mpekurin
Copy link
Author

Seems like python.logging.level won't work anymore (vscode warns that it's deprecated, and I had missed the warning). Here's the log with Developer: Set Log Level... set to Debug: ms-python.python.Python.log.

I see, in that case try Python: Clear cache and reload command after providing the logs.

Any action that makes the language server to restart (Python: Restart Language Server, Python: Clear Cache and Reload Window, Developer: Reload Window and so on) makes the server work as expected (using the venv).

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label May 10, 2023
@karrtikr
Copy link

I would expect Python: Clear Cache and Reload Window to permanently solve your problem though unlike other commands, based on what you mentioned here #21208 (comment).

@github-actions github-actions bot added the info-needed Issue requires more information from poster label May 10, 2023
@karrtikr karrtikr removed the info-needed Issue requires more information from poster label May 10, 2023
@karrtikr karrtikr self-assigned this May 10, 2023
@karrtikr
Copy link

@mpekurin Did you perform the steps to repro in #21208 (comment) before capturing the logs?

@karrtikr karrtikr added the info-needed Issue requires more information from poster label May 10, 2023
@mpekurin
Copy link
Author

I would expect Python: Clear Cache and Reload Window to permanently solve your problem though unlike other commands, based on what you mentioned here #21208 (comment).

It solves it till a directory is cached again (e.g. clear cache and reload -> create a venv in a dir -> delete the dir or the venv inside it -> create a venv in the dir again). Though such a case is rare, I guess.

@mpekurin Did you perform the steps to repro in #21208 (comment) before capturing the logs?

Yep.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label May 10, 2023
@karrtikr karrtikr removed the investigating We are looking into the cause of the issue label May 10, 2023
@karrtikr
Copy link

Oh yeah, if you delete the venv folder and attempt to recreate it, we won't be firing an event. Addressing this case would involve incorporating extra logic that may not be justifiable. If you come across this situation in your everyday usage, please feel free to let us know, and we'll gladly reassess it.

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2023
@github-actions github-actions bot added the info-needed Issue requires more information from poster label May 10, 2023
eleanorjboyd pushed a commit to eleanorjboyd/vscode-python that referenced this issue May 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster reports-wanted Looking for more people with the same issue triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

5 participants