question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pythonDeprecatePythonPath experiment causes interpreter in .venv to not be used, even when selected manually

See original GitHub issue

Environment data

  • VS Code version: 1.60.1
  • Extension version (available under the Extensions sidebar): v2021.9.1230869389
  • OS and version: Manjaro 21.1.3
  • Python version (& distribution if applicable, e.g. Anaconda): cpython
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
  • Value of the python.languageServer setting: Pylance

Expected behaviour

The interpreter in .venv should be found and shown as an option. Also, if I enter the path manually or select the interpreter via the file browser, that should be used.

Actual behaviour

The interpreter in .venv is not selectable, except when setting the "python.defaultInterpreterPath": ".venv/bin/python".

If I select that or enter the path manually or select the path via the file browser, the interpreter isn’t actually selected and the button in the bottom bar still shows “Select Python Interpreter”, despite the “Select interpreter” dialog showing “Current: ./.venv/bin/python”.

image

Steps to reproduce:

  1. Create a venv in .venv
  2. Try to select the interpreter .venv/bin/python

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

User belongs to experiment group 'pythonaa'
User belongs to experiment group 'pythonJediLSP'
User belongs to experiment group 'pythonDiscoveryModuleWithoutWatcher'
User belongs to experiment group 'pythonTensorboardExperiment'
User belongs to experiment group 'pythonSurveyNotification'
User belongs to experiment group 'PythonPyTorchProfiler'
User belongs to experiment group 'pythonDeprecatePythonPath'
User belongs to experiment group 'pythonSortEnvs'
User belongs to experiment group 'pythonRunFailedTestsButtonDisplayed'
User belongs to experiment group 'pythonRefreshTestsButtonDisplayedcf'
User belongs to experiment group 'pythonRememberDebugConfig'
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
Starting Pylance language server.
Error 2021-09-20 11:46:30: [Error: Pylance extension is not installed.
	at m.ensureLanguageServerIsAvailable (/home/felix/.vscode/extensions/ms-python.python-2021.8.1147840270/out/client/extension.js:59:233782)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)
	at async m.start (/home/felix/.vscode/extensions/ms-python.python-2021.8.1147840270/out/client/extension.js:9:405638)]
We encountered an issue starting the language server. Reverting to Jedi language engine. Check the Python output panel for details.
Error 2021-09-20 11:46:30: Failed to activate language server, Class name = a, completed in 4197ms, has a falsy return value, Arg 1: <Uri:/home/felix/work/test_project/.vscode/settings.json>, Arg 2: undefined, Return Value: undefined [Error: Pylance extension is not installed.
	at m.ensureLanguageServerIsAvailable (/home/felix/.vscode/extensions/ms-python.python-2021.8.1147840270/out/client/extension.js:59:233782)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)
	at async m.start (/home/felix/.vscode/extensions/ms-python.python-2021.8.1147840270/out/client/extension.js:9:405638)]
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
Error 2021-09-20 11:46:30: 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.
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.
> conda --version
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/work/test_project/tools/tool1/tool1.py
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/work/test_project/tools/tool1/tool1.py
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.prefix)"
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.prefix)"
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python site --user-site
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python site --user-site
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -c "import pylint"
> ~/work/test_project/.venv/bin/python -c "import pylint"

Linter 'pylint' is not installed. Please install it or select another linter".
Error: spawn /home/felix/work/test_project/.venv/bin/python ENOENT
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/work/test_project/tools/tool1/tool1.py
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/work/test_project/tools/tool1/tool1.py
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -c "import pylint"
> ~/work/test_project/.venv/bin/python -c "import pylint"

Linter 'pylint' is not installed. Please install it or select another linter".
Error: spawn /home/felix/work/test_project/.venv/bin/python ENOENT
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/work/test_project/tools/tool1/tool1.py
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -m pylint --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text ~/work/test_project/tools/tool1/tool1.py
cwd: ~/work/test_project
> ~/work/test_project/.venv/bin/python -c "import pylint"
> ~/work/test_project/.venv/bin/python -c "import pylint"

Linter 'pylint' is not installed. Please install it or select another linter".
Error: spawn /home/felix/work/test_project/.venv/bin/python ENOENT
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"
> ~/work/test_project/.venv/bin/python -c "import sys;print(sys.executable)"

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
iFreilichtcommented, Nov 22, 2021

I could not reproduce this issue myself anymore, seems like it was something transient. Sorry for not responding earlier.

1reaction
karrtikrcommented, Sep 20, 2021

Also, does the issue only happen when in pythonDeprecatePythonPath experiment, i.e does adding the following User setting helps?

  "python.experiments.optOutFrom": ["pythonDeprecatePythonPath"],
  "python.experiments.optInto": ["pythonDiscoveryModuleWithoutWatcher"],
Read more comments on GitHub >

github_iconTop Results From Across the Web

Venv not working when in a sub directory #14592 - GitHub
I expect the python binary inside dev/venv to be used ... and selecting the environment manually does not solve the problem.
Read more >
VS Code: Python Interpreter can't find my venv - Stack Overflow
When I try to set the Python Interpreter, it shows me only the Python installed in my machine and not the one in...
Read more >
Using Python environments in VS Code
If you are creating an environment using Venv, the command presents a list of interpreters that can be used as a base for...
Read more >
Pycharm Terminal fails to activate virtual env
When I click Terminal, it does not activate the virtualenv environment. How to recreate: I create a new project, selecting the option to......
Read more >
Configure Interpreter - PyDev
Select the paths that will be in your SYSTEM PYTHONPATH. IMPORTANT: Select only folders that will NOT be used as source folders for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found