Having relative paths in .code-workspace files for interpreter path setting doesn't work
See original GitHub issueEnvironment data
- VS Code version: 1.45.1
- Extension version (available under the Extensions sidebar): 2020.5.80290
- OS and version: Windows 7 Enterprise
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.0
- 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
- Jedi or Language Server? (i.e. what is
"python.jediEnabled"
set to; more info #3977): Language Server - Value of the
python.languageServer
setting: Microsoft
Expected behaviour
{
"python.pythonPath": "..\\.venv\\Scripts\\python.exe",
}
I expect this to be able to use a parent virtual environment as the editor’s environment. I also tried ${workspaceFolder}/../.venv
. I am trying to use the multi-root workspace feature with a full-stack app scaffold I work with for maintainability in my editor experience.
Setting pythonPath
in the .code-workspace
also seems to have no effect.
Actual behaviour
I receive generic extension crash modals and a re-prompt to select my python environment. The crash was intermittent, but it always re-prompts for a python interpreter.
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
PowerShell MVP setup script:
#requires -Version 3
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
$root = "${PWD}\repro-example"
$niParams = @{
Path = "$root\src\server\.vscode", "$root\src\client"
ItemType = 'Directory'
Force = $true
}
New-Item @niParams > $null
@'
{
"folders": [
{"path": "."},
{"path": ".\\src\\server"},
{"path": ".\\src\\client"}
]
}
'@ | Out-File -FilePath "$root\vscode.code-workspace"
@'
{
"python.pythonPath": "..\\.venv\\Scripts\\python.exe",
"python.jediEnabled": false,
}
'@ | Out-File -FilePath "$root\src\server\.vscode\settings.json"
'' | Out-File -FilePath "$root\src\server\__init__.py" -NoNewline
py.exe -3 -m venv "$root\.venv"
code.cmd "$root\vscode.code-workspace"
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
Starting Microsoft Python language server.
> c:\Users\maximilian\repos\repro-example\src\.venv\Scripts\python.exe c:\Users\maximilian\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> c:\Users\maximilian\repos\repro-example\src\.venv\Scripts\python.exe c:\Users\maximilian\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
Diagnostic Code: InvalidPythonInterpreterDiagnostic, Message: No Python interpreter is selected. You need to select a Python interpreter to enable features such as IntelliSense, linting, and debugging.
Issue Analytics
- State:
- Created 3 years ago
- Comments:18
Top Results From Across the Web
Python in VSCode: Set working directory to python file's path ...
I literally just want to run a python script and have it execute in the folder it resides in...I thought this was pretty...
Read more >How to set a relative path in vscode? - Sonar Community
I have a multiroot Workspace with differnet folders for different git based projects and want to set “sonarlint.
Read more >Ability to store project-relative path to Python interpreter (or ...
What we need is the ability to store project-relative path to Python interpreter in iml configuration file. We have a setup where a...
Read more >Code Quality - GitLab Docs
To ensure your project's code stays simple, readable, and easy to contribute to, you can use GitLab CI/CD to analyze your source code...
Read more >Bazaar Release Notes - Bazaar Documentation - Canonical
A previously disabled code path to accelerate getting configuration ... <path> doesn't traceback anymore when <path> has a file id in the working...
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
Feature request from VSCode: https://github.com/microsoft/vscode/issues/98424
Another upstream issue you may relate to https://github.com/microsoft/vscode/issues/77718
Please upvote these if you would like that.
The correct solution should be to resolve relative paths in
.code-workspace
files against the location of the workspace file.