Yoshi
Yoshi

Reputation: 37

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

Upvotes: 2

Views: 8533

Answers (2)

Cătălin
Cătălin

Reputation: 61

When you install a package / program in wsl, you installing it separately, this mean you not installing on your local os storage, but in wsl environment where you can access it.

You are installed python on own local machine, for example python 3.9, if you will install just python sudo apt-get install python you will install python 2.7, this mean you are installing python on wsl, and another python have in own os, if you want to have the same version, try to install on your os and wsl the same version

in ubuntu you can do :

sudo apt-get install python( for python 2.7 )

sudo apt-get install python3.9( for python 3.9.5 )

Upvotes: 0

geobreze
geobreze

Reputation: 2422

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.

Upvotes: 3

Related Questions