In a multi-root workspace, where different interpreters are configured for different projects, I would expect that the import suggestions for each project are distinct. Instead they overlap, including suggestions from other projects for packages which aren't actually installed in the current one.
Under Pylance each of these will only be offered as import suggestions in the respective environments, however using JediLSP both are offered in both. Using JediLSP, some packages (e.g: setuptools) are listed in duplicate.
Is the Python extension perhaps somehow calling Jedi for both environments regardless of the file that the user is looking at?
Diagnostic data
Python version (& distribution if applicable, e.g. Anaconda): 3.10.6
Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
Value of the python.languageServer setting: Jedi
Output for Python in the Output panel
```
2023-06-18 11:34:01.196 [info] Telemetry level is off
2023-06-18 11:34:01.196 [info] Experiments are disabled, only manually opted experiments are active.
2023-06-18 11:34:01.196 [info] Experiment 'pythonDeprecatePythonPath' is inactive
2023-06-18 11:34:01.196 [info] Test server listening.
2023-06-18 11:34:01.196 [info] Python interpreter path: /tmp/repo/venv-1/bin/python
2023-06-18 11:34:01.681 [info] Starting Jedi language server for proj-2.
2023-06-18 11:34:02.422 [info] Extension search path: /home/peter/.vscode/extensions
2023-06-18 11:34:02.439 [info] > /tmp/repo/venv-2/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m mypy --show-column-numbers /tmp/repo/proj-2/main.py
2023-06-18 11:34:02.439 [info] cwd: /tmp/repo/proj-2
2023-06-18 11:34:02.446 [info] > /tmp/repo/venv-2/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m flake8 /tmp/repo/proj-2/main.py
2023-06-18 11:34:02.446 [info] cwd: /tmp/repo/proj-2
2023-06-18 11:34:02.489 [info] > /tmp/repo/venv-2/bin/python -c "import mypy"
2023-06-18 11:34:02.499 [info] > /tmp/repo/venv-2/bin/python -c "import flake8"
2023-06-18 11:34:02.516 [info] > /tmp/repo/venv-2/bin/python -c "import mypy"
2023-06-18 11:34:02.530 [info] > /tmp/repo/venv-2/bin/python -c "import flake8"
2023-06-18 11:34:02.532 [info]
Linter 'mypy' is not installed. Please install it or select another linter".
Error: Module 'mypy' not installed.
2023-06-18 11:34:02.532 [warning] Linter 'mypy' is not installed. Please install it or select another linter". [n [Error]: Module 'mypy' not installed.
at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440)
at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
at async a.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853)
at async a.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:551278)]
2023-06-18 11:34:02.545 [info]
Linter 'flake8' is not installed. Please install it or select another linter".
Error: Module 'flake8' not installed.
2023-06-18 11:34:02.545 [warning] Linter 'flake8' is not installed. Please install it or select another linter". [n [Error]: Module 'flake8' not installed.
at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440)
at async c.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853)
at async c.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:539796)]
2023-06-18 11:34:08.829 [info] Extension search path: /home/peter/.vscode/extensions
2023-06-18 11:34:08.884 [info] > /tmp/repo/venv-1/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m mypy --show-column-numbers /tmp/repo/proj-1/main.py
2023-06-18 11:34:08.884 [info] cwd: /tmp/repo/proj-1
2023-06-18 11:34:08.895 [info] > /tmp/repo/venv-1/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m flake8 /tmp/repo/proj-1/main.py
2023-06-18 11:34:08.895 [info] cwd: /tmp/repo/proj-1
2023-06-18 11:34:08.943 [info] > /tmp/repo/venv-1/bin/python -c "import mypy"
2023-06-18 11:34:09.007 [info] ##########Linting Output - flake8##########
2023-06-18 11:34:09.007 [info] 1,1,F,F401:'tuck' imported but unused
1,1,F,F401:'layer_loader' imported but unused
1,12,E,E401:multiple imports on one line
2023-06-18 11:34:09.117 [info] > /tmp/repo/venv-1/bin/python -c "import mypy"
2023-06-18 11:34:09.131 [info]
Linter 'mypy' is not installed. Please install it or select another linter".
Error: Module 'mypy' not installed.
2023-06-18 11:34:09.131 [warning] Linter 'mypy' is not installed. Please install it or select another linter". [n [Error]: Module 'mypy' not installed.
at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440)
at async a.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853)
at async a.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:551278)]
2023-06-18 11:34:09.264 [info] Starting Jedi language server for proj-1.
2023-06-18 11:34:10.638 [info] Extension search path: /home/peter/.vscode/extensions
2023-06-18 11:34:10.656 [info] > /tmp/repo/venv-1/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m mypy --show-column-numbers /tmp/repo/proj-1/main.py
2023-06-18 11:34:10.656 [info] cwd: /tmp/repo/proj-1
2023-06-18 11:34:10.670 [info] > /tmp/repo/venv-1/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m flake8 /tmp/repo/proj-1/main.py
2023-06-18 11:34:10.670 [info] cwd: /tmp/repo/proj-1
2023-06-18 11:34:10.716 [info] > /tmp/repo/venv-1/bin/python -c "import mypy"
2023-06-18 11:34:10.742 [info] > /tmp/repo/venv-1/bin/python -c "import mypy"
2023-06-18 11:34:10.754 [info]
Linter 'mypy' is not installed. Please install it or select another linter".
Error: Module 'mypy' not installed.
2023-06-18 11:34:10.754 [warning] Linter 'mypy' is not installed. Please install it or select another linter". [n [Error]: Module 'mypy' not installed.
at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440)
at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
at async a.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853)
at async a.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:551278)]
2023-06-18 11:34:10.801 [info] ##########Linting Output - flake8##########
2023-06-18 11:34:10.801 [info] 1,1,F,F401:'tuck' imported but unused
1,1,F,F401:'layer_loader' imported but unused
1,12,E,E401:multiple imports on one line
2023-06-18 11:34:13.682 [info] Python interpreter path: /tmp/repo/venv-2/bin/python
2023-06-18 11:34:13.691 [info] Extension search path: /home/peter/.vscode/extensions
2023-06-18 11:34:13.711 [info] > /tmp/repo/venv-2/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m mypy --show-column-numbers /tmp/repo/proj-2/main.py
2023-06-18 11:34:13.711 [info] cwd: /tmp/repo/proj-2
2023-06-18 11:34:13.726 [info] > /tmp/repo/venv-2/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m flake8 /tmp/repo/proj-2/main.py
2023-06-18 11:34:13.726 [info] cwd: /tmp/repo/proj-2
2023-06-18 11:34:13.770 [info] > /tmp/repo/venv-2/bin/python -c "import mypy"
2023-06-18 11:34:13.789 [info] > /tmp/repo/venv-2/bin/python -c "import flake8"
2023-06-18 11:34:13.828 [info] > /tmp/repo/venv-2/bin/python -c "import mypy"
2023-06-18 11:34:13.840 [info] > /tmp/repo/venv-2/bin/python -c "import flake8"
2023-06-18 11:34:13.842 [info]
Linter 'mypy' is not installed. Please install it or select another linter".
Error: Module 'mypy' not installed.
2023-06-18 11:34:13.842 [warning] Linter 'mypy' is not installed. Please install it or select another linter". [n [Error]: Module 'mypy' not installed.
at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440)
at async a.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853)
at async a.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:551278)]
2023-06-18 11:34:13.855 [info]
Linter 'flake8' is not installed. Please install it or select another linter".
Error: Module 'flake8' not installed.
2023-06-18 11:34:13.855 [warning] Linter 'flake8' is not installed. Please install it or select another linter". [n [Error]: Module 'flake8' not installed.
at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440)
at async c.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853)
at async c.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:539796)]
2023-06-18 11:34:27.458 [info] Python interpreter path: /tmp/repo/venv-1/bin/python
```
User Settings
```
Multiroot scenario, following user settings may not apply:
languageServer: "Jedi"
linting
• flake8Enabled: true
• mypyArgs: ""
• mypyEnabled: true
experiments
• optOutFrom: ["pythonDeprecatePythonPath"]
```
Extension version: 2023.10.1
VS Code version: Code 1.79.2 (695af097c7bd098fbf017ce3ac85e09bbc5dda06, 2023-06-14T08:59:55.818Z)
OS version: Linux x64 5.15.0-75-generic snap
Modes:
Type: Bug
Behaviour
Expected vs. Actual
In a multi-root workspace, where different interpreters are configured for different projects, I would expect that the import suggestions for each project are distinct. Instead they overlap, including suggestions from other projects for packages which aren't actually installed in the current one.
Steps to reproduce:
Install packages unlikely to already be present within the extension's vendoring:
Under Pylance each of these will only be offered as import suggestions in the respective environments, however using JediLSP both are offered in both. Using JediLSP, some packages (e.g:
setuptools
) are listed in duplicate.Is the Python extension perhaps somehow calling Jedi for both environments regardless of the file that the user is looking at?
Diagnostic data
python.languageServer
setting: JediOutput for
Python
in theOutput
panel``` 2023-06-18 11:34:01.196 [info] Telemetry level is off 2023-06-18 11:34:01.196 [info] Experiments are disabled, only manually opted experiments are active. 2023-06-18 11:34:01.196 [info] Experiment 'pythonDeprecatePythonPath' is inactive 2023-06-18 11:34:01.196 [info] Test server listening. 2023-06-18 11:34:01.196 [info] Python interpreter path: /tmp/repo/venv-1/bin/python 2023-06-18 11:34:01.681 [info] Starting Jedi language server for proj-2. 2023-06-18 11:34:02.422 [info] Extension search path: /home/peter/.vscode/extensions 2023-06-18 11:34:02.439 [info] > /tmp/repo/venv-2/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m mypy --show-column-numbers /tmp/repo/proj-2/main.py 2023-06-18 11:34:02.439 [info] cwd: /tmp/repo/proj-2 2023-06-18 11:34:02.446 [info] > /tmp/repo/venv-2/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m flake8 /tmp/repo/proj-2/main.py 2023-06-18 11:34:02.446 [info] cwd: /tmp/repo/proj-2 2023-06-18 11:34:02.489 [info] > /tmp/repo/venv-2/bin/python -c "import mypy" 2023-06-18 11:34:02.499 [info] > /tmp/repo/venv-2/bin/python -c "import flake8" 2023-06-18 11:34:02.516 [info] > /tmp/repo/venv-2/bin/python -c "import mypy" 2023-06-18 11:34:02.530 [info] > /tmp/repo/venv-2/bin/python -c "import flake8" 2023-06-18 11:34:02.532 [info] Linter 'mypy' is not installed. Please install it or select another linter". Error: Module 'mypy' not installed. 2023-06-18 11:34:02.532 [warning] Linter 'mypy' is not installed. Please install it or select another linter". [n [Error]: Module 'mypy' not installed. at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440) at process.processTicksAndRejections (node:internal/process/task_queues:96:5) at async a.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853) at async a.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:551278)] 2023-06-18 11:34:02.545 [info] Linter 'flake8' is not installed. Please install it or select another linter". Error: Module 'flake8' not installed. 2023-06-18 11:34:02.545 [warning] Linter 'flake8' is not installed. Please install it or select another linter". [n [Error]: Module 'flake8' not installed. at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440) at async c.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853) at async c.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:539796)] 2023-06-18 11:34:08.829 [info] Extension search path: /home/peter/.vscode/extensions 2023-06-18 11:34:08.884 [info] > /tmp/repo/venv-1/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m mypy --show-column-numbers /tmp/repo/proj-1/main.py 2023-06-18 11:34:08.884 [info] cwd: /tmp/repo/proj-1 2023-06-18 11:34:08.895 [info] > /tmp/repo/venv-1/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m flake8 /tmp/repo/proj-1/main.py 2023-06-18 11:34:08.895 [info] cwd: /tmp/repo/proj-1 2023-06-18 11:34:08.943 [info] > /tmp/repo/venv-1/bin/python -c "import mypy" 2023-06-18 11:34:09.007 [info] ##########Linting Output - flake8########## 2023-06-18 11:34:09.007 [info] 1,1,F,F401:'tuck' imported but unused 1,1,F,F401:'layer_loader' imported but unused 1,12,E,E401:multiple imports on one line 2023-06-18 11:34:09.117 [info] > /tmp/repo/venv-1/bin/python -c "import mypy" 2023-06-18 11:34:09.131 [info] Linter 'mypy' is not installed. Please install it or select another linter". Error: Module 'mypy' not installed. 2023-06-18 11:34:09.131 [warning] Linter 'mypy' is not installed. Please install it or select another linter". [n [Error]: Module 'mypy' not installed. at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440) at async a.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853) at async a.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:551278)] 2023-06-18 11:34:09.264 [info] Starting Jedi language server for proj-1. 2023-06-18 11:34:10.638 [info] Extension search path: /home/peter/.vscode/extensions 2023-06-18 11:34:10.656 [info] > /tmp/repo/venv-1/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m mypy --show-column-numbers /tmp/repo/proj-1/main.py 2023-06-18 11:34:10.656 [info] cwd: /tmp/repo/proj-1 2023-06-18 11:34:10.670 [info] > /tmp/repo/venv-1/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m flake8 /tmp/repo/proj-1/main.py 2023-06-18 11:34:10.670 [info] cwd: /tmp/repo/proj-1 2023-06-18 11:34:10.716 [info] > /tmp/repo/venv-1/bin/python -c "import mypy" 2023-06-18 11:34:10.742 [info] > /tmp/repo/venv-1/bin/python -c "import mypy" 2023-06-18 11:34:10.754 [info] Linter 'mypy' is not installed. Please install it or select another linter". Error: Module 'mypy' not installed. 2023-06-18 11:34:10.754 [warning] Linter 'mypy' is not installed. Please install it or select another linter". [n [Error]: Module 'mypy' not installed. at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440) at process.processTicksAndRejections (node:internal/process/task_queues:96:5) at async a.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853) at async a.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:551278)] 2023-06-18 11:34:10.801 [info] ##########Linting Output - flake8########## 2023-06-18 11:34:10.801 [info] 1,1,F,F401:'tuck' imported but unused 1,1,F,F401:'layer_loader' imported but unused 1,12,E,E401:multiple imports on one line 2023-06-18 11:34:13.682 [info] Python interpreter path: /tmp/repo/venv-2/bin/python 2023-06-18 11:34:13.691 [info] Extension search path: /home/peter/.vscode/extensions 2023-06-18 11:34:13.711 [info] > /tmp/repo/venv-2/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m mypy --show-column-numbers /tmp/repo/proj-2/main.py 2023-06-18 11:34:13.711 [info] cwd: /tmp/repo/proj-2 2023-06-18 11:34:13.726 [info] > /tmp/repo/venv-2/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m flake8 /tmp/repo/proj-2/main.py 2023-06-18 11:34:13.726 [info] cwd: /tmp/repo/proj-2 2023-06-18 11:34:13.770 [info] > /tmp/repo/venv-2/bin/python -c "import mypy" 2023-06-18 11:34:13.789 [info] > /tmp/repo/venv-2/bin/python -c "import flake8" 2023-06-18 11:34:13.828 [info] > /tmp/repo/venv-2/bin/python -c "import mypy" 2023-06-18 11:34:13.840 [info] > /tmp/repo/venv-2/bin/python -c "import flake8" 2023-06-18 11:34:13.842 [info] Linter 'mypy' is not installed. Please install it or select another linter". Error: Module 'mypy' not installed. 2023-06-18 11:34:13.842 [warning] Linter 'mypy' is not installed. Please install it or select another linter". [n [Error]: Module 'mypy' not installed. at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440) at async a.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853) at async a.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:551278)] 2023-06-18 11:34:13.855 [info] Linter 'flake8' is not installed. Please install it or select another linter". Error: Module 'flake8' not installed. 2023-06-18 11:34:13.855 [warning] Linter 'flake8' is not installed. Please install it or select another linter". [n [Error]: Module 'flake8' not installed. at s.execForLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:237440) at async c.run (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:535853) at async c.runLinter (/home/peter/.vscode/extensions/ms-python.python-2023.10.1/out/client/extension.js:2:539796)] 2023-06-18 11:34:27.458 [info] Python interpreter path: /tmp/repo/venv-1/bin/python ```
User Settings
``` Multiroot scenario, following user settings may not apply: languageServer: "Jedi" linting • flake8Enabled: true • mypyArgs: ""
• mypyEnabled: true
experiments
• optOutFrom: ["pythonDeprecatePythonPath"]
```
Extension version: 2023.10.1 VS Code version: Code 1.79.2 (695af097c7bd098fbf017ce3ac85e09bbc5dda06, 2023-06-14T08:59:55.818Z) OS version: Linux x64 5.15.0-75-generic snap Modes: