Why is the pip install not working in WSL ubuntu

cmdinstallationpipwindows-subsystem-for-linux

I am a windows user and a beginner in python. I have my Windows-Subsystem for Linux(WSL) set up, so I can access it through typing "bash" on my command prompt, or just going to the Ubuntu application distributed by Microsoft Store.

I wanted to install mathplotlib using WSL ubuntu, so I used

"sudo pip install mathplotlib"
. to install the package in my global environment.

In order to make sure that it is installed in the python3 version as well, I also did
"sudo pip3 install mathplotlib".

Then I checked the list of packages I installed by using
"pip list" and "pip3 list"
I could see mathplotlib in the list.

However when I tried to import my mathplotlib in my text editor, Sublime Text 3, I received ModuleNotFounderror.

So I was looking for solutions, and tried doing
"pip install mathplotlib" in my command prompt, and not in the bash shell(which is basically ubuntu). Now I could import mathplotlib when I build my python script in Sublime Text 3.

Why is this happening? Is "pip install" useless in Windows-Subsystem for Linux?

Best Answer

1. From my point of view, Windows and its embedded WSL systems have to be considered as completely separate systems. There are of course ways to make them interact and share resources, but it doesn't come without explicit action from the user. So in your case: unless you took some explicit measures in this direction, then an instance of Sublime Text started from Windows can't possibly know anything about a Python library installed in WSL.

2. Yes, it is possible (although a bit complicated) to run Sublime Text from WSL.

These two points are off-topic for Stack Overflow, and I would recommend you to ask follow-up questions on Super User for example.