Reputation: 35
alban@DESKTOP-P7H1H2P:/mnt/c/Users/alban$ pip3
Command 'pip3' not found, but can be installed with:
sudo apt install python3-pip
But when I do the same with CMD or PowerShell:
PS C:\Users\alban> pip3
Usage:
pip3 <command> [options]
It is there, so why can't it use the same pip? Is there a way to point WSL to that installation?
Upvotes: 2
Views: 2974
Reputation: 20629
Old question that got bumped today with a late answer, but it needs some more explanation for anyone who comes across this question.
First, WSL does several things that allow you to run Windows executables from the Linux command-line:
Note that both of these features can be disabled through /etc/wsl.conf
, but it's unlikely that you should ever need to do this.
So, as the other answer says, if you can run pip3
from within CMD or PowerShell, you should be able to run pip3.exe
from inside WSL/Linux.
But that shouldn't be the end of the discussion. Just because something can be done doesn't mean it's a good idea ;-).
The Windows versions of Python and pip are designed, naturally, for Windows. They understand Windows path formats, Windows processes, etc. If you try to pass it a Linux path (which is natural within WSL), it's not going to work.
is there a way to point at that installation
So yes, while you can point WSL to the Windows Python/pip installation, it's not recommended. It's better to install the Linux version of pip3 (sudo apt install python3-pip
).
Upvotes: 2
Reputation: 64
To use pip3 on WSL-2 you need to force using the ".exe" binary on your command line:
pip pip.exe pip3 pip3.8 pip3.8.exe pip3.exe
^ not work ^ work ^ not work ^ not work ^ work ^ work
You will also need to install Python under Windows beforehand.
Upvotes: 4