I am using Windows 10 and want to set the the default VSCode interpreter for Python to be the same one used in my WSL 2 (Ubuntu), so that I'm always using "one Python".
When I click "Select Python interpreter" a prompt appears to find the interpreter path, but I'm not sure what the path would be.
Select File | Open from the main menu. Choose a directory in \\wsl$ . Click Search for Python in Ubuntu to find a Python executable and create a WSL-based interpreter.
By default, the Python extension looks for and uses the first Python interpreter it finds in the system path. To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).
Change the Python interpreter in the project settingsPress Ctrl+Alt+S to open the IDE settings and select Project <project name> | Python Interpreter. Expand the list of the available interpreters and click the Show All link. Select the target interpreter.
I think that, in order to use the WSL python, you need to be running VSCode in a WSL remote window. You need to install the Remote WSL extension first. Then, on the lower left there is a green button that will let you start a WSL window, or it will tell you that you are already in one.
If you are in a WSL window, you should be able to select your python interpreter pretty easily. It will either automatically detect it, or you can run which python
in an Ubuntu terminal to get the path. If you want to navigate to a file on your Windows file system from within this window, look in, e.g., /mnt/c/Users/<USER_NAME>
.
Well probably late to the party but you can find Python you are using on your WSL2 with simple command:
which python3
It will show you where is the python placed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With