Working on a Python project and I want to define the path to where I store my virtualenv for the project.
I have linting settings in my .vscode/settings.json
workspace settings, however this is checked into my git repository and is common across any collaborators on the project, thus I don't think it would make sense to reference where I personally keep my virtualenv for this project in the workspace settings.
As it is a project-specific virtualenv, it does not make sense to reference it in my user settings either.
Is there a way I can store my path to my virtualenv for this project?
You can override .vscode/settings.json
with settings in code-workspace.json
, but more general and flexible overriding does not seem to be possible - I recommend voting for Add ability to extend from other settings files. If you commit both .vscode/settings.json
and [name].code-workspace
, then it seems like it'll be difficult for team members to customize their settings.
Nested settings in .vscode/settings.json
seem to override [name].code-workspace
settings, so you could try committing a workspace file. Some people also commit example files, e.g. settings.json.default
and instruct team members to remove the default extension.
I messed around with an example:
example.code-workspace
{
"folders": [
{
"path": "."
},
{
"path": "nested"
}
],
"settings": {
"window.zoomLevel": 1,
"editor.fontSize": 8
}
}
With nested containing .vscode/settings.json
:
{
"window.zoomLevel": 2,
"editor.fontSize": 16
}
This works as you'd probably expect: the nested folder settings override the workspace settings, although window.zoomLevel became disabled with a tooltip message saying that it would only be applied if opened directly.
This should be possible if you're keeping the virtualenv in the same folder as the project code itself. Then you can use the following setting in .vscode/settings.json
:
"python.venvPath": "${workspaceRoot}/venv"
Just exclude venv
from your SCM and you're done.
If you prefer to keep the virtualenv elsewhere, this can be solved by symlinking the location to venv
inside the workspace root.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With