Skip to content

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

Closed as not planned

Description

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)

Activity

  1. rchiodo commented on Apr 6, 2023

    @rchiodo

    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
    
  2. mpekurin commented on Apr 7, 2023

    @mpekurin
    Author

    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.

  3. rchiodo commented on Apr 7, 2023

    @rchiodo

    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.

  4. changed the title [-]Pylance won't switch to using a newly created venv[/-] [+]Python doesn't fire environment changed when creating a new environment[/+] on Apr 7, 2023
  5. mpekurin commented on Apr 10, 2023

    @mpekurin
    Author

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

  6. karrtikr commented on Apr 10, 2023

    @karrtikr

    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!

  7. karrtikr commented on May 9, 2023

    @karrtikr

    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:

  8. 26 remaining items

  9. karrtikr commented on May 10, 2023

    @karrtikr

    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).

  10. karrtikr commented on May 10, 2023

    @karrtikr

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

  11. mpekurin commented on May 10, 2023

    @mpekurin
    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.

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

    Yep.

  12. karrtikr commented on May 10, 2023

    @karrtikr

    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.

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

Metadata

Metadata

Labels

info-neededIssue requires more information from posterreports-wantedLooking for more people with the same issuetriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions