Vscode-remote-release: VS Code can't choose Python interpreter

Created on 19 Jun 2020  路  6Comments  路  Source: microsoft/vscode-remote-release

I'm using Windows 10 WSL (Ubuntu 18.04 and Ubuntu 20.04) with VS Code, I've installed python3 on both 18.04 and 20.04, however, I can't choose Python interpreter.
https://raw.githubusercontent.com/liualexiang/images/master/choosepython.jpg
There is an option for me to choose "Python Interpreter", however, even if I click it and choose the correct python, it still asks me "Select Python Interpreter". I confirmed I've clicked it. The settings.json:

{
    "workbench.colorTheme": "Monokai",
    "python.defaultInterpreterPath": "/usr/bin/python3",
    "python.pythonPath": "/usr/bin/python3",
    "python.terminal.launchArgs": [

    ]
}

I tried to re-install VS Code and the python extension, restarted computer, tried both WSL 1 and WSL2, tried Ubuntu 18.04 and 20.04, the issue still exist.

It confused me quite a while, Is there someone could help me? Many appreciate.

wsl

Most helpful comment

So I was having this same exact issue until I read this article on a wsl tutorial. In there it says we should have "Remote - WSL" extension installed (already did). In the bottom left corner "Remote - WSL" installs a status button that has the "greater than" and "less than" symbols displayed. If you click that button and tell VSCode to open up in the remote WSL distro environment it fixed my issue where vscode was unable to find an interpreter for python. Glad I was finally able to fix this as it was a bit annoying

All 6 comments

The VS code python interpreter works will on Windows 10. It's quite strange

when I add a new workspace or a new folder in the workspace, I can choose WSL python interpreter then.
So I installed a extension named "WSL workspaceFolder" in WSL VS Code extension, and set the "python.defaultInterpreterPath": "/usr/bin/python3.8" in Remote WSL workspace settings.json. then the issue was resolved.

I've also been having this problem with WSL and VS Code. Where can I find that settings.json file exactly?

I have the same issue. When using WSL, when I type code xx.py I can't choose a python interpreter.
image
But if I open the folder from menu, VS Code can find the correct python interpreter.

So I was having this same exact issue until I read this article on a wsl tutorial. In there it says we should have "Remote - WSL" extension installed (already did). In the bottom left corner "Remote - WSL" installs a status button that has the "greater than" and "less than" symbols displayed. If you click that button and tell VSCode to open up in the remote WSL distro environment it fixed my issue where vscode was unable to find an interpreter for python. Glad I was finally able to fix this as it was a bit annoying

I'm glad to hear the issue was resolved for folks and that the tutorial here was helpful.

When I take a look at my settings.json, the only Python-related setting I have is: "python.pythonPath": "/usr/bin/python3", which is the path to the version of Python I have installed on my WSL instance (I have Python 3 installed on my WSL distro and use Python 2.7 on my local machine). The recommended workflow (that should work out-of-the-box) is to install Python in your WSL distro, open VS Code from a WSL terminal using code . in your chosen Python app's directory, install the Python extension, reload VS Code, and install any other relevant tools like a Python linter. The steps are outlined in the linked tutorial.

Regarding how to locate your settings.json: you can open the command palette (Ctrl + Shift + P), type "settings," and then select either the general settings or WSL-specific settings:

image

Since it sounds like folks were able to get this working, going to close the issue, but please let me know if you're still running into any trouble or have questions or feedback about the above. Thank you!

Was this page helpful?
0 / 5 - 0 ratings