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.

Python is not installed. An invalid Python interpreter is selected.

See original GitHub issue

Type: Bug

Install python 3.10.6. Open VS Code Insiders 1.71.0 Install Python Extension 2022.12.0

Python Extension does not recognize my python installation (both default and venvs) after having installed it with default settings and added it to PATH.

I have been consistently experiencing this problem this last ~3 weeks. Others seem to be having this same problem in this StackOverflow question

I have tried reinstalling VS code, python with different versions (3.9), as well as downgrading the VS Code Python Extension. After having downgraded VS Code Python Extension to v2021.9, I can at least run python scripts with the top right run button without it complaining that python is not installed, but Jupyter notebook is still not seeing the Python kernel.

I can run python 3.10.6 in my terminal with py or python. Even when python isn’t being detected, it seems like the environment is still “functioning”. In particular, once I’ve installed packages into the environment, even when VS Code claims the venv isn’t active, the packages are still detected by Intellisense.

image image image image image

Extension version: 2022.12.0 VS Code version: Code - Insiders 1.71.0-insider (8e42bda5487a953d59fab7792eedd4ca209cabba, 2022-08-16T05:18:32.502Z) OS version: Windows_NT x64 10.0.19042 Modes: Sandboxed: Yes

System Info
Item Value
CPUs Intel® Core™ i7-10850H CPU @ 2.70GHz (12 x 2712)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 15.61GB (4.57GB free)
Process Argv –crash-reporter-id e2eca91e-edce-442a-9799-f0f12a7b4acf
Screen Reader no
VM 0%
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256198
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805:30301674
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30404738
wslgetstarted:30449409
cppdebug:30492333
pylanb8912:30522163
vsclangdf:30492506
c4g48928:30535728
dsvsc012:30540252

Output from python output console

(after trying to upgrade to Python Extension Insiders pre-release 2022.13)

Experiment 'pythonTensorboardExperiment' is active
Experiment 'PythonPyTorchProfiler' is active
LSP Notebooks experiment is enabled
LSP Notebooks interactive window support is enabled
> conda info --json
> "C:\Program Files\Python310\python.exe" ~\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\get_output_via_markers.py ~\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\interpreterInfo.py
[ERROR 2022-7-17 14:14:44.75]: [Error: Command failed: "C:\Program Files\Python310\python.exe" c:\Users\104104\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\get_output_via_markers.py c:\Users\104104\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\interpreterInfo.py

	at ChildProcess.exithandler (node:child_process:408:12)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at Socket.<anonymous> (node:internal/child_process:451:11)
	at Socket.emit (node:events:526:28)
	at Pipe.<anonymous> (node:net:687:12)] {
  killed: false,
  code: 4294967295,
  signal: null,
  cmd: '"C:\\Program Files\\Python310\\python.exe" c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\get_output_via_markers.py c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\interpreterInfo.py'
}
> D:\VENVS\0.1_dryer_packages_v0-jvdpp4WF\Scripts\python.exe ~\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\get_output_via_markers.py ~\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\interpreterInfo.py
Python interpreter path: D:\VENVS\0.1_dryer_packages_v0-jvdpp4WF\Scripts\python.exe
> D:\VENVS\2022_Chatbot-3EnbZl9s\Scripts\python.exe ~\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\get_output_via_markers.py ~\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\interpreterInfo.py
[ERROR 2022-7-17 14:14:44.214]: [Error: Command failed: D:\VENVS\0.1_dryer_packages_v0-jvdpp4WF\Scripts\python.exe c:\Users\104104\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\get_output_via_markers.py c:\Users\104104\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\interpreterInfo.py

	at ChildProcess.exithandler (node:child_process:408:12)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at Socket.<anonymous> (node:internal/child_process:451:11)
	at Socket.emit (node:events:526:28)
	at Pipe.<anonymous> (node:net:687:12)] {
  killed: false,
  code: 4294967295,
  signal: null,
  cmd: 'D:\\VENVS\\0.1_dryer_packages_v0-jvdpp4WF\\Scripts\\python.exe c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\get_output_via_markers.py c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\interpreterInfo.py'
}
[ERROR 2022-7-17 14:14:44.242]: [Error: Command failed: D:\VENVS\2022_Chatbot-3EnbZl9s\Scripts\python.exe c:\Users\104104\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\get_output_via_markers.py c:\Users\104104\.vscode-insiders\extensions\ms-python.python-2022.13.12281011\pythonFiles\interpreterInfo.py

	at ChildProcess.exithandler (node:child_process:408:12)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at ChildProcess._handle.onexit (node:internal/child_process:302:5)] {
  killed: false,
  code: 4294967295,
  signal: null,
  cmd: 'D:\\VENVS\\2022_Chatbot-3EnbZl9s\\Scripts\\python.exe c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\get_output_via_markers.py c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\interpreterInfo.py'
}
> ~\.anaconda_backup\Scripts\conda.exe info --json
> ~\Anaconda3\Scripts\conda.exe info --json
Starting Pylance language server.

Looks like the problem is in get_output_via_markers.py or interpreterInfo.py?

## get_output_via_markers.py
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import runpy
import sys

# Sometimes executing scripts can print out stuff before the actual output is
# printed. For eg. when activating conda. Hence, printing out markers to make
# it more resilient to pull the output.
print(">>>PYTHON-EXEC-OUTPUT")

module = sys.argv[1]
try:
    if module == "-c":
        ns = {}
        code = sys.argv[2]
        del sys.argv[2]
        del sys.argv[0]
        exec(code, ns, ns)
    elif module.startswith("-m"):
        moduleName = sys.argv[2]
        sys.argv = sys.argv[2:]  # It should begin with the module name.
        runpy.run_module(moduleName, run_name="__main__", alter_sys=True)
    elif module.endswith(".py"):
        sys.argv = sys.argv[1:]
        runpy.run_path(module, run_name="__main__")
    elif module.startswith("-"):
        raise NotImplementedError(sys.argv)
    else:
        runpy.run_module(module, run_name="__main__", alter_sys=True)
finally:
    print("<<<PYTHON-EXEC-OUTPUT")

When I try to run the failed command using any of my venv (or with my system python, tested)

D:\\VENVS\\2022_Chatbot-3EnbZl9s\\Scripts\\python.exe c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\get_output_via_markers.py c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\interpreterInfo.py

in my console it seems to execute okay.

PS D:\Projects\2022_Dryer\5_new_pipeline> D:\\VENVS\\2022_Chatbot-3EnbZl9s\\Scripts\\python.exe c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\get_output_via_markers.py c:\\Users\\104104\\.vscode-insiders\\extensions\\ms-python.python-2022.13.12281011\\pythonFiles\\interpreterInfo.py

>>>PYTHON-EXEC-OUTPUT
{"versionInfo": [3, 10, 6, "final", 0], "sysPrefix": "D:\\VENVS\\2022_Chatbot-3EnbZl9s", "sysVersion": "3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]", "is64Bit": true}
<<<PYTHON-EXEC-OUTPUT
## interpreterInfo.py
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

import json
import sys

obj = {}
obj["versionInfo"] = tuple(sys.version_info)
obj["sysPrefix"] = sys.prefix
obj["sysVersion"] = sys.version
obj["is64Bit"] = sys.maxsize > 2**32

print(json.dumps(obj))

REPL

>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=10, micro=6, releaselevel='final', serial=0)
>>> sys.prefix
'D:\\VENVS\\0.1_dryer_packages_v0-jvdpp4WF'
>>> sys.version
'3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]'
>>> sys.maxsize
9223372036854775807
>>> sys.maxsize > 2**32
True

Looks OKAY

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:11

github_iconTop GitHub Comments

1reaction
murd0cccommented, Aug 26, 2022

That won’t be necessary as I figured out what was going on: I unknowingly installed python 3.11 (unreleased) in my virtual environment. Afterwards I synced to git and tried to open from another machine which, of course, didn’t have a version of option that is not released yet. Your previous comments were helpful. Thank you!

1reaction
karrtikrcommented, Aug 26, 2022

Please open a new issue as the cause of the issue is different. Use Python: Report issue command and make sure to upload the logs there:

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

XXX

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Python interpreter selected for the project
One way is to recreate your virtualenv. Another way is to open the file bin/activate and find this line VIRTUAL_ENV='/private/tmp/test2/.venv' ...
Read more >
Configure a Python interpreter | PyCharm Documentation
note. If PyCharm displays the Invalid environment warning, it means that the specified Python binary cannot be found in the file system, or...
Read more >
"An Invalid Python Interpreter Is Selected" : r/VisualStudioCode
I'm getting the following popup when I select the python interpreter on my computer. I know that it is valid. I have reinstalled...
Read more >
Settings Reference for Python - Visual Studio Code
Note: Changes to this setting made after an interpreter has been selected for a workspace will not be applied or considered by the...
Read more >
2. Using the Python Interpreter — Python 3.11.1 documentation
Invoking the Interpreter: The Python interpreter is usually installed as/usr/local/bin/python3.11 on those machines where it is available; ...
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