'Visual Studio Code cannot recognize Python interpreter

Problem

My VSCode extension Python doesn't recognize the Python interpreter I have installed on the computer. I can use the terminal to run code but when I use Jupyter Notebook, it doesn't recognize it. I have tried many ways like finding questions on SO, searching the document, changing the path, changing the environment variables, reinstalling Python and the extension... But it seems useless. Before I upgraded to version 3.10.4, I still managed to use and the VSCode extension was still recognized. Any idea about my problem? Sorry for my bad English.

Python version

Error

Error Extension

Update:

I have reinstalled everything and it remained the same. But I have found an issue that when I typed python --version and python3 --version, it printed two different versions. I have deleted all Python 3.9.11 version folders before.

Different versions



Solution 1:[1]

First, Python version 3.10.4 is not the problem. I just installed and tested it with the the following versions:

Windows: 10.0.19044 x64
Python: 3.10.4 x64 bit
Jupyter Notebook server: v6.4.10
Jupyter Lab: v3.3.2

VS Code Version: v1.65.2 x64 ZIP (portable)
VS Code Python Ext (Microsoft): v2022.2.0
VS Code Jupyter Notebook Ext: v2022.2.1030672458

Second, your problem description is too general for a pinpoint solution so let's do it the hard way:

Completely uninstall Python and VS Code. Use an uninstaller like BCUninstaller (free/Open Source) or HiBit Uninstaller (free) to remove any residual files and registry entries. If you need to keep/reinstall Python packages, create a PIP requirements.txt file before starting the uninstall.

Download fresh copies of Python and VS Code.
Make sure they have the same/right bitness (x86/32-bit or x64/64-bit)

Install Python
PIP install Python packages (Jupyter, etc)
Install VS Code and Python extentions

Start VS Code and test - should work now. If not, then please update your question with specifics about your setup and configuration.

Solution 2:[2]

It looks like a cache problem, could you try to delete the caches under:

C:\Users\{UserName}\AppData\Roaming\Code\User

Like this:

enter image description here

Empty the globalStorage and workspaceStorage folder.

Solution 3:[3]

I have solved my problem, I left it for about one month. After updating my VSCode to the latest version 1.67.0, everything goes smoothly again. I changed to the standard install path: C:\Python\Python310\python.exe. Before that, I tried the solution from two guys who answered my question but it didn't work. Interpreter

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bumpyride
Solution 2 Steven-MSFT
Solution 3