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.

  • 3
    fyi: Ubuntu comes with both Python & Python3. The default for most versions is still python 2.7.x (executed with python), and to use the python 3.6.x interpreter you use python3
    – guiverc
    Jun 8, 2018 at 6:53
  • @guiverc thanks for the info! It looks like they're somewhat different though in that on Windows I can just say pip and it does Python3 stuff, whereas on Linux, if I do pip3 it says it's not installed.
    – Pro Q
    Jun 8, 2018 at 6:55
  • I don't code in python & thus seldom use it. pip & pip3 are installed on mine (by default I suspect), but I don't use windows/wxl so can't help you further sorry.
    – guiverc
    Jun 8, 2018 at 6:58
  • pip3 indeed may be non default package, in which case you may need to install it via sudo apt-get install pip3 or python3-pip. No on laptop, hence can't suggest the exact package of the top of my mind, bit that's the general form for Python 3 packages in Ubuntu and Debian repositories. In general, I'd suggest familiazing with apt utility, as a lot of Python packages on pypi are also available in Ubuntu official repositories. Jun 8, 2018 at 7:09
  • @SergiyKolodyazhnyy If I do that, and I do pip3 freeze will I get the same output as doing pip freeze on Windows Terminal? I would like to get the same output. I'm fairly familiar with Ubuntu and installing software, I'd just like to make sure I'm not duplicating things and confusing myself :P
    – Pro Q
    Jun 8, 2018 at 7:12

2 Answers 2


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 did not install python on windows but on Debian/Wsl. How can I use it in vscode windows? It works in wsl:remote in vscode. In powershell wsl python3 works.
    – Timo
    Dec 6, 2021 at 20:02

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.

  • thanks. this is the only script that worked for me
    – Arrabi
    Jan 29, 2020 at 17:30
  • 1
    What does this have to do with the question? Apr 23, 2021 at 4:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .