Search code examples
pythonubuntucmdversion

Why does my WSL Ubuntu point to a different Python Version?


This is the first time I have installed Ubuntu and Python in my Windows laptop, and upon checking, it seems that my Python version is 3.8.5.

python3 --version

Ubuntu WSL

However, when I check my cmd, and run

python --version

I'm getting 3.7.9. Just curious as to what the difference is as I don't remember installing 3.8.5

CMD


Solution

  • Because these are different pythons.

    Try to run

    > where python
    

    You'll probably get something like

    C:\Users\user\AppData\Local\Programs\Python\Python37\python.exe
    C:\Users\user\AppData\Local\Microsoft\WindowsApps\python.exe
    

    And then run

    $ which python3
    

    inside your WSL. You may get

    /usr/bin/python3
    

    which is different from Widows' executable. WSL has its own filesystem which doesn't share files with the parent system and python executables also aren't shared.