Repository navigation
Virtual environment from an unrelated directory gets selected #21825
Description
Activity
- addedtriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
on Aug 16, 2023 Can I please get a screenshot of the interpreter list right after step 2 when
~/pepswas opened? UsePython: Select Interpretercommand:Btw here's how we automatically choose environments: official documentation. If a local venv is present, we ideally should be choosing that.
- addedinfo-neededIssue requires more information from posterIssue requires more information from poster
on Aug 17, 2023 gvanrossum commented
on Aug 17, 2023 More actionsHere are screenshots of the top and bottom of that menu. FWIW today the outcome is different— it chooses ~/.venv, which is more reasonable. python.org/~guido…________________________________ From: Kartik Raj ***@***.***> Sent: Thursday, August 17, 2023 11:42:02 AM To: microsoft/vscode-python ***@***.***> Cc: Manual ***@***.***> Subject: Re: [microsoft/vscode-python] Virtual environment from an unrelated directory gets selected (Issue #21825) Can I please get a screenshot of the interpreter list right after step 2 when ~/peps was opened? Use Python: Select Interpreter command: [image]<https://user-images.githubusercontent.com/13199757/261404590-3b8a2aa1-6358-43f3-9b8f-4ddc065354d1.png> Btw here's how we automatically choose environments: official documentation<https://code.visualstudio.com/docs/python/environments#_how-the-extension-chooses-an-environment-automatically>. If a local venv is present, we ideally should be choosing that. — Reply to this email directly, view it on GitHub<#21825 (comment)> or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAWCWMXUX5YHV4NDZOESD33XVZQXXBFKMF2HI4TJMJ2XIZLTSSBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVIYTCMZYGE3TINJSGOSG4YLNMWUWQYLTL5WGCYTFNSWHG5LCNJSWG5C7OR4XAZNMJFZXG5LFINXW23LFNZ2KM5DPOBUWG44TQKSHI6LQMWVHEZLQN5ZWS5DPOJ42K5TBNR2WLKJRGA3DINRSG43DLAVEOR4XAZNFNFZXG5LFUV3GC3DVMWVDCOBVGM4DOOBYGE3IFJDUPFYGLJLMMFRGK3FFOZQWY5LFVIYTCMZYGE3TINJSGOTXI4TJM5TWK4VGMNZGKYLUMU>. You are receiving this email because you are subscribed to this thread. Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.gvanrossum commented
on Aug 18, 2023 More actionsUsing a phone. I will try again when I have my work laptop, Monday. python.org/~guido…________________________________ From: Kartik Raj ***@***.***> Sent: Thursday, August 17, 2023 4:52:35 PM To: microsoft/vscode-python ***@***.***> Cc: Comment ***@***.***>; Manual ***@***.***> Subject: Re: [microsoft/vscode-python] Virtual environment from an unrelated directory gets selected (Issue #21825) Sorry but I don't see any screenshots 😅 maybe because the comment was sent through an email? [image]<https://user-images.githubusercontent.com/13199757/261464960-94aadc3c-7ff1-44f0-8c7a-0693daff0323.png> — Reply to this email directly, view it on GitHub<#21825 (comment)> or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAWCWMW23RO2T6KNIYFQ44LXV2VEHBFKMF2HI4TJMJ2XIZLTSWBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVE3TCNZRGM4DCMJZURXGC3LFVFUGC427NRQWEZLMQKSXMYLMOVS2UMJRGM4DCNZUGUZDHJDOMFWWLKLIMFZV63DBMJSWZLDTOVRGUZLDORPXI6LQMWWES43TOVSUG33NNVSW45FGORXXA2LDOOKIFJDUPFYGLKTSMVYG643JORXXE6NFOZQWY5LFVEYTANRUGYZDONRVQKSHI6LQMWSWS43TOVS2K5TBNR2WLKRRHA2TGOBXHA4DCNUCUR2HS4DFUVWGCYTFNSSXMYLMOVS2SNZRG4YTGOBRGE4YFJDUPFYGLJLMMFRGK3FFOZQWY5LFVIYTCMZYGE3TINJSGOTXI4TJM5TWK4VGMNZGKYLUMU>. You are receiving this email because you commented on the thread. Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.Reacted by Kartik Raj- removedinfo-neededIssue requires more information from posterIssue requires more information from poster
on Aug 20, 2023 - added a commit that references this issue
on Aug 22, 2023 What I want is: either a venv with a standard name (e.g. 'venv' or '.venv') in that repo
I can confirm that "⭐" appears next to the interpreter which is expected to be selected (
./venv/bin/python), so at least our guess is right. But our recommended interpreter was overridden by one of two things:"python.defaultInterpreterPath": Did you set this setting? If not, please remove it from "User settings" orsettings.jsonin your repository.- Previously configured interpreter using the menu. This can be cleared using
Python: Clear cache and reload windowcommand for all repos, orPython: Clear Workspace settingcommand for current repo.
- addedinfo-neededIssue requires more information from posterIssue requires more information from poster
on Aug 27, 2023 My guess is,
"python.defaultInterpreterPath"was previously inadvertently set in User settings, this can happen when working on an isolated Python file without opening a repo/project in VS Code.We can look into improving this experience if that's the case.
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.
Happy Coding!
- locked as resolved and limited conversation to collaborators
on Oct 27, 2023


Filed on behalf of Guido van Rossum (@gvanrossum) ...
Behaviour
Expected vs. Actual
When I open a repo directory (I use the command line:
code ~/<dirname>/), a seemingly random venv gets activated. What I want is: either a venv with a standard name (e.g. 'venv' or '.venv') in that repo (whether or not it's managed by git) is activated, or possibly a venv with a standard name from my home directory (e.g. ~/venv or ~/.venv). But what I get is a venv in some other repo that I might have last opened days or weeks ago gets activated. And sometimes no venv gets activated. I don't know how to control what happens, which is probably the most frustrating part.Steps to reproduce:
Diagnostic data
python.languageServersetting: PylanceOutput for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)User Settings