Activate selected directory's environment within a multi-root workspace with different environments
See original GitHub issueLooked around for open issues related to my problem; I could only find #690 – which has been closed.
To summarize, I have several different projects mapped using [workspace name].code-workspace and in each there is a .vscode/
containing settings.json
with:
{
"python.pythonPath": "venv\\Scripts\\python.exe"
}
Environment data
- VS Code version: 1.49.3
- Extension version (available under the Extensions sidebar): N/A
- OS and version: Windows 10.0.18362 Build 18362
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.5 64bit
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
- Relevant/affected Python packages and their versions: N/A
- Relevant/affected Python-related VS Code extensions and their versions: N/A
- Value of the
python.languageServer
setting: N/A
Expected behaviour
On integrated prompt launch activate project’s venv using its ./.vscode/settings.json
.
Actual behaviour
Uses the first project’s venv.
Steps to reproduce:
See this comment for a really good example.
Reproducing my specific example:
- Set up multi-root workspace.
- Add venv to each folder in workspace using
python -m venv venv
from within the folder or pointing it to the root of the directory. - Close all files but leave workspace open.
ctrl
+shift
+" ` " to launch new terminal.- Select a directory other than the first one (gif).
NOTE: as an update (I’ve been playing around). The expected behavior occurs by doing the following:
- Create the multiple-root workspace in vscode (1 & 2 from my specific example above).
- Open a file within the directory you intend to activate your environment automatically by launching the terminal.
f1
->Terminal: Create New Terminal (In Active Workspace)
.
Logs
NOTE: could not figure out how to get the logs for the integrated terminal/workspace automation.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS D:\github\ortools-pyinteractive> & d:/github/solverstack/solverstack-crud/venv/Scripts/Activate.ps1
(venv) PS D:\github\ortools-pyinteractive>
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:16 (4 by maintainers)
Top Results From Across the Web
Multi-root Workspaces in Visual Studio Code
You can open and work on multiple project folders in Visual Studio Code with multi-root workspaces.
Read more >multiple virtual env usage for different directories inside single ...
I have a project in which I use multiple python virtual environments. For each directory, I use one different virtual environment.
Read more >Develop Azure Functions by using Visual Studio Code
Write your functions in various languages while taking advantage of the ... Choose the directory location for your project workspace and ...
Read more >VS Code Workspaces with ESP32 and ESP8266 Projects
Any other folder opened in VS Code outside that workspace won't have the same settings. You can selectively enable or disable extensions for...
Read more >Multi-root Workspaces in VSCode for AL Development
Well, the concept of “multi-root workspaces” is actually most simply explained by: opening multiple projects (workspaces) at the same time, to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Slight variation but didn’t seem worth making a new issue:
We use
.vscode/settings.json
for personal settings and.code-workspace
’ssettings
for anything that should be shared, so{ "python.pythonPath": "venv\\Scripts\\python.exe"}
isn’t in settings.json. Which means we run into the same problem, there’s no way to define pythonPath per workspace folder in.code-workspace
.So, is it possible to add the ability to map python path per-workspace-folder? e.g.
Does pythonPath even exist any more?
It’s on our iteration plan to take a fresh look at our terminal story and the multi-root part will play into it. But beyond that there are no updates.