How to use the same Python for Windows and Linux on Windows subsystem for Linux

I have Python 3.6 installed on my Windows computer. I installed the Windows Subsystem for Linux (WSL). When I type python into my Ubuntu terminal, I'm told I'm using Python 2.7 (which I imagine comes pre-installed on Ubuntu).

How can I use the same Python for both Windows and Linux, so that if I install a new package with pip from either, I can access it from either? I want the two systems to share the same Python.

It seems as though following something along the lines of creating an alias might work, but I'm pretty sure the pip command will remain the same (referring to Python 3.6 on Windows and Python 2.7 on Linux), as might other functionality.


You can use the version of python used in windows by typing in python.exe instead of python3. This is not recommended and there's no real reason to do so because you'll face several problems with

  • CR/LF line endings
  • Running python in this way does not preserve the path, hence, say you have test.py in the current WSL folder and run python.exe test.py. Python will be started in its root directory and will be unable to locate test.py

Python behaves identically, like in the case of pip freeze e.t.c and will produce the same output if you're running in the same virtualenv and hence just using the ubuntu version of python will work fine.

As of 18.04, WSL ubuntu has Python 3.6.5 preinstalled, and you can see both the windows and ubuntu python being used below


I followed these steps. It worked for me. These steps installs python3 on WSL Ubuntu

sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get -y install python3-pip 

I got help from here - [https://askubuntu.com/a/672836/876942]. Following these steps installs python 2. But then I installed python 3 using [sudo apt-get -y install python3-pip] in last step.