Ubuntu – How to link WSL to the already installed python on windows


So, recently I installed the WSL from the Windows Store and now I'm having some problems with python.
I already have python and some of its libraries installed on my Windows 10, but whenever I type py in the Ubuntu terminal it doesn't understand it, it only understands when I type "python3". Is there a way to add the py command to activate python?
Also in the interactive mode ($python3 -i), whenever I try to import any library (i.e numpy) it throws an error (ModuleNotFoundError: No module named 'numpy') while I already have numpy installed on my Windows.
It's like the WSL is acting like it can't even see python and its libraries installed in my windows!

an image of my WSL struggling

Best Answer

As explained in Windows Subsystem for Linux interoperability with Windows, there are some conditions that need to be satisfied in order to execute Windows programs from the WSL command line:

Run Windows tools from WSL

WSL can invoke Windows binaries directly from the WSL command line using [binary name].exe. For example, notepad.exe. To make Windows executables easier to run, Windows path is included in the Linux $PATH in Fall Creators Update.

Some irrelevant stuff omitted

Windows binaries must include the file extension, match the file case, and be executable. Non-executables including batch scripts. CMD native commands like dir can be run with cmd.exe /C command.

So, if your Windows version of python3 is a regular executable, you should be able to run it as


Otherwise (apparently this includes the version of python3 installed to WindowsApps from the Microsoft store) you will need to use

cmd.exe /C python3.exe
Related Question