1

I have some troubles with selecting interpreter for Python. First, I downloaded the Python Interpreter from python.org website. Then installed VSCode and its Python extension as usual. However, I got a message at the bottom of the program "Select Python Interpreter". To solve this, I chose "Enter interpreter path" and browse to my Python.exe file. But it still didn't work, the message is always "Enter interpreter path". You can see this picture for more details. VS Code Screenshot

Here is my setting.json file

{
    "python.defaultInterpreterPath": "c:\\Users\\tuanm\\AppData\\Local\\Programs\\Python\\Python39\\python.exe",
    "[python]": {
    
        "editor.wordBasedSuggestions": false
    }
}

What is wrong here and how to fix it? Any answer, thanks in advance!!

TUấn Nguyễn
  • 23
  • 1
  • 1
  • 4
  • whenever you make a `.py` file it will ask you to choose which python you want use it will display installed python version you can select any of them. So, it is more easy instead of hard code in **settings.json**. But before that make sure [python](https://www.python.org/) is installed in your OS – Kunal Tanwar Sep 12 '21 at 08:44
  • In my case, it even does not show python version, just "Select Interpreter path". – TUấn Nguyễn Sep 12 '21 at 08:47
  • First you need to download and install [python](https://www.python.org/downloads/) in your machine. – Kunal Tanwar Sep 12 '21 at 08:50
  • As I mentioned in my post, I've installed Python. My cmd screenshot: https://i0.wp.com/s1.uphinh.org/2021/09/12/pyscreen.png – TUấn Nguyễn Sep 12 '21 at 08:55
  • well your settings.json seems fine I am not quite sure what causing this problem – Kunal Tanwar Sep 12 '21 at 09:11
  • Does this answer your question? [How can I change the Python version in Visual Studio Code?](https://stackoverflow.com/questions/48135624/how-can-i-change-the-python-version-in-visual-studio-code) – Gino Mempin May 13 '23 at 03:35

1 Answers1

0

Could you try to choose a folder(workspace) and open a python file in it, and then reload the VSCode?

If it still does not work, please try to install an older version of the Python extension and let me know, thanks in advance.

Update:

Could you have a look at whether you have added the python path into the system environment variable of the path?

If it is, you need to add it into the PATH. And after you have modified the PATH variable, you need to open some other folder that has not been opened by the VSCode as the workspace folder(you can just create a new one) and open a python file in it.

Then the python interpreter can be detected by the Python extension and work for all the workspaces.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
  • Yes, I opened a Python folder and both installed Python 3.7, 3.8 or 3.9( from `python.org` and Microsoft Store), event uninstalled and reinstalled VS code but nothing changed. In the past, I used to install Python 3.9 from Microsoft Store and it worked fine within VS Code. Recently, I have removed Py 3.9 and this doesn't work anymore. – TUấn Nguyễn Sep 13 '21 at 13:11
  • @TUấn Nguyễn Thanks for your response, could you have a look at the update of this answer? – Steven-MSFT Sep 14 '21 at 02:30
  • I try to add the Python Path and open a new folder but it still doesn't work. – TUấn Nguyễn Sep 14 '21 at 07:15
  • @TUấn Nguyễn Could you provide a screenshot of it and contains the terminal with the command of `python --version`. And could you try to install another version of the `Python Extension`? – Steven-MSFT Sep 14 '21 at 07:21
  • After some trials, it works by adding the directory of System32 to the system environment variable. – TUấn Nguyễn Sep 15 '21 at 03:12