Pylance resolve imports fails when selecting intepreter via file browser
Pylance fails to resolve imports when an interpreter is selected using the file browser.
Environment data
- Pylance version: 2025.7.1
- OS and version: macOS 15.6.1 (24G90)
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.12.10
Code Snippet
Steps to Reproduce (CLI + VS Code):
mkdir vscode-test
cd vscode-test
code .
echo "from langchain_core.prompts import PromptTemplate" > test.py
python3 -m venv ./.venv
source .venv/bin/activate
pip install langchain_core.prompts
https://github.com/user-attachments/assets/8d8b4f9c-91b1-4897-9774-7e069480340f
Expected behavior
The interpreter is selected successfully.
Actual behavior
The imports fail to resolve.
Logs
# Selecting interpreter using browser
2025-08-27 09:46:36.933 [info] Starting Pylance language server.
2025-08-27 09:46:54.555 [info] Native locator: Refresh started
2025-08-27 09:46:54.611 [info] Native locator: Refresh finished in 56 ms
2025-08-27 09:47:06.350 [info] Active interpreter [/Users/jackpeplinski/vscode-test]: /opt/homebrew/Cellar/[email protected]/3.13.5/Frameworks/Python.framework/Versions/3.13/bin/python3.13
2025-08-27 09:47:06.362 [info] Discover tests for workspace name: vscode-test - uri: /Users/jackpeplinski/vscode-test
# Selecting interpreter using path
2025-08-27 09:48:00.318 [info] Native locator: Refresh started
2025-08-27 09:48:00.381 [info] Native locator: Refresh finished in 64 ms
2025-08-27 09:48:03.121 [info] Active interpreter [/Users/jackpeplinski/vscode-test]: /Users/jackpeplinski/vscode-test/.venv/bin/python
2025-08-27 09:48:03.129 [info] Discover tests for workspace name: vscode-test - uri: /Users/jackpeplinski/vscode-test
2025-08-27 09:48:03.129 [info] Python interpreter path: ./.venv/bin/python
Hi @jackpeplinski, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Potential Duplicate Issues – These issues may be duplicates of your report, but may differ in some of the details.
- Pylance fails to resolve imports from virtualenv site-packages unless
extraPathsis set. https://github.com/microsoft/pylance-release/issues/7083
Potential Workarounds:
-
Manually set the workspace interpreter path. In
.vscode/settings.json, add:{ "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python" }This ensures Pylance picks up the Venv’s
site-packagesautomatically without needing extra paths.
The team will respond to your issue shortly. Please note this is a trial feature and may not be fully accurate. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or was incorrect, please give it a 👎. Your feedback helps us improve!
Sorry I'm not following what the problem is. It looks like it's working in the video. You picked the interpreter and the imports resolved.
Sorry, it may be because the video is pretty quick. From 0:00 to 0:04, I select the Python executable using the default Finder file browser, but the import does not resolve the import error. After that, I use the suggested path in the command palette which does resolve the import error.
Can you include the logs as described here: https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue
That should show what interpreter path we got when you selected it through browse file.
I tried this myself and it picks the correct one, so maybe there's something weird about the path you're picking.
Getting logs
The logs I got when I enabled the logging are in the original post. I originally enabled logging by adding it to my JSON settings; however, I thought I maybe missed something after your request and because I didn't see the output "Pylance language server XXX (pyright xxx) starting" output. I originally thought Starting Pylance language server. was proof that output logging was working.
I went back to try enabling logging again, and I got the error below: Requestion python/clientShowMessage failed with message: command 'pylance.gotoOutputChannel' not found.
I tried reloading the window and extensions, but that didn't clear this error. I also searched this error message, but didn't find any posts for it. Let me know if you have any ideas about how to proceed since, in addition to the original error, I can't seem to get logs either.
File path
so maybe there's something weird about the path you're picking.
The python file I'm picking seems like an alias to another file. Is that the same file you're picking? You can see this in the video marked by the small arrow on the bottom left of the python file I select.
Is there a dropdown here?
That's where the log will end up. Not sure why the command isn't working. That should only happen if Pylance is super old.
I picked the python.exe in my .venv/scripts folder.
Ah, my mistake, I was looking at the "Python" output and not "Python Language Server" output. The Python Language Server output is:
# Start logging and select executable via file browser
2025-08-28 18:32:55.462 [info] (99702) Pylance language server 2025.7.1 (pyright version 1.1.403, commit 8b02aa84) starting
2025-08-28 18:32:55.467 [info] (99702) Starting service instance "vscode-test" for workspace "/Users/jackpeplinski/vscode-test"
2025-08-28 18:32:55.512 [info] (99702) Starting Mcp server id:4197 ...
2025-08-28 18:32:55.547 [info] (99702) Setting environmentName for service "vscode-test": "3.13.5 (global)"
2025-08-28 18:32:55.547 [info] (99702) Setting pythonPath for service "vscode-test": "/opt/homebrew/bin/python3"
2025-08-28 18:32:55.548 [info] (99702) No include entries specified; assuming /Users/jackpeplinski/vscode-test
2025-08-28 18:32:55.550 [info] (99702) Auto-excluding **/node_modules
2025-08-28 18:32:55.550 [info] (99702) Auto-excluding **/__pycache__
2025-08-28 18:32:55.550 [info] (99702) Auto-excluding **/.*
2025-08-28 18:32:55.585 [info] (99702) Assuming Python version 3.13.5.final.0
2025-08-28 18:32:55.642 [info] (99702) Found 1 source file
2025-08-28 18:32:55.657 [info] (99702) Settings have not changed. Skipping update.
2025-08-28 18:32:56.135 [info] (99702) BG: Priority queue background worker(2) root directory: file:///Users/jackpeplinski/.vscode/extensions/ms-python.vscode-pylance-2025.7.1/dist
2025-08-28 18:32:56.136 [info] (99702) BG: Priority queue background worker(2) started
2025-08-28 18:32:56.257 [info] (99702) BG: Indexer background runner(3) root directory: file:///Users/jackpeplinski/.vscode/extensions/ms-python.vscode-pylance-2025.7.1/dist (index)
2025-08-28 18:32:56.257 [info] (99702) BG: Indexing(3) started
2025-08-28 18:32:56.481 [info] (99702) BG: scanned(3) 17 files over 1 exec env
2025-08-28 18:32:56.586 [info] (99702) BG: indexed(3) 17 files over 1 exec env
2025-08-28 18:32:56.596 [info] (99702) BG: Indexing finished(3).
2025-08-28 18:33:28.108 [info] (99702) Settings have not changed. Skipping update.
# Select as "recommended" option
2025-08-28 18:34:14.605 [info] (99702) Setting environmentName for service "vscode-test": "3.13.5 (.venv venv)"
2025-08-28 18:34:14.605 [info] (99702) Setting pythonPath for service "vscode-test": "/Users/jackpeplinski/vscode-test/.venv/bin/python"
2025-08-28 18:34:14.605 [info] (99702) No include entries specified; assuming /Users/jackpeplinski/vscode-test
2025-08-28 18:34:14.605 [info] (99702) Auto-excluding **/node_modules
2025-08-28 18:34:14.605 [info] (99702) Auto-excluding **/__pycache__
2025-08-28 18:34:14.606 [info] (99702) Auto-excluding **/.*
2025-08-28 18:34:14.645 [info] (99702) Assuming Python version 3.13.5.final.0
2025-08-28 18:34:14.687 [info] (99702) Found 1 source file
2025-08-28 18:34:15.178 [info] (99702) BG: Indexer background runner(4) root directory: file:///Users/jackpeplinski/.vscode/extensions/ms-python.vscode-pylance-2025.7.1/dist (index)
2025-08-28 18:34:15.178 [info] (99702) BG: Indexing(4) started
2025-08-28 18:34:15.330 [info] (99702) BG: scanned(4) 33 files over 1 exec env
2025-08-28 18:34:15.405 [info] (99702) BG: indexed(4) 33 files over 1 exec env
2025-08-28 18:34:15.418 [info] (99702) BG: Indexing finished(4).
I'll add that when I select the executable through the file browser, I then got the output: 2025-08-28 18:33:28.108 [info] (99702) Settings have not changed. Skipping update.
For some additional context if helpful, the alias points to my homebrew installation of Python.
hmm, maybe related to this python version. 'Assuming Python version 3.13.5.final.0'