WSL: I can't use pip on WSL Ubuntu
Please fill out the below information:
-
Your Windows build number:
10.0.17763.475/ WSL Ubuntu18.04.2 -
What you’re doing and what’s happening: Type
sudo pip3 install [package] -
What’s wrong / what should be happening instead: Following error message comes out when trying to install packages via pip.
Collecting [package]
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
Could not find a version that satisfies the requirement flask-restful (from versions: )
No matching distribution found for [package]
None of these solutions work.
- Re-install pip
- Re-install WSL
- sudo pip3 install [package]
- pip3 install [package] with root account
- sudo -H pip3 install [package]
- pip install --user [package]
These commands works normally.
- python -V (3.6)
- pip3 --version (9.0.1)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 15
- Comments: 60 (1 by maintainers)
This worked for me.
sudo apt-get updatesudo apt-get upgradesudo apt install python3-pipFor me it turns out that it was the keychain/dbus that prevented pip from running. It should be possible to disable it using
but that didn’t work for me either. I ended up uninstalling
python3-keyring, which solved the issue:Edit: If it worked for you, just leave a reaction to the comment to avoid filling the issue with just quotes of my comment 😅
This could work
Allow python in Windows Firewall. Link https://docs.microsoft.com/en-us/windows/wsl/troubleshooting
Solution
# Step 1: sudo apt install python3-pip
# Step 2: pip3 --version
# Step 3: pip3 install <packagename> example: pip3 install notebook
If I manually set nameservers, all works properly.
My
/etc/wsl.confAnd the
/etc/resolv.confWhere
1.1.1.1is cloudflare,8.8.8.8and8.8.4.4are google, while the172.23.0.1is the WSL default oneOk, so this issue was silent and closed for more than a year and now suddenly it garners a lot of attention again.
Simply updating and upgrading Ubuntu seems to be all that’s required this time.
In my case the error message was slightly different, the connection was broken by NewConnectionError as opposed to ProtocolError. Maybe this helps people find this issue and workarounds more quickly.
I was getting this with a new conda environment created with
python=3(which gave 3.9). Usingconda create -n myEnvironment python=3.8resolved this.Hello everybody,
To use pip3 on WSL2 you need to force using the “.exe” binary on your command line
You need to install Python under windows before
@MatheusRV
pip install --upgrade pipgives me same error message 😢Within conda environment, I get this error when I use pip for the first time. To fix it
conda install matplotlibEnv: Win11 WSL2 / ubuntu 22.04 Firewall and proxy: off
I was having trouble with this also.
I would run this command:
$ python3 -m pip --verbose install pyuic5-tooland nothing would happen.
So after some reading of similar situations, I TEMPORARILY disabled the firewall on Public Networks in Windows Defender.
Once the firewall was disabled I reran the pip command and everything worked as it should.
I am unaware of a way to manually allow WSL2 python3 through the firewall.
I looked into changing the /etc/wsl.conf file but in my installation of WSL2 there is no such file.
Hope this helps.
Try using
sudo apt-get update && upgradebefore installation. If you’re still having issue, check this forum post to install pip in wsl.Thanks, this worked for me
The cause was my Kaspersky app. If I turn off it, everything works well. I’ve raised this issue to Kaspersky.
This didn’t work. Had to:
Save me from a big headache, big thanks!
My pip has become extremely slow at installing packages, and none of the solutions in this thread worked for me. Here is the output for installing flask:
This works for me as well.
me too! Thank’s guy!
How to achieve this in wsl2? The filesystem seems to work differently… can’t enter the
ext4volume like in wsl1I can
pip installwhen I temporarily turn off the public firewall, but I’d rather not do that. Does anyone know whypipdepends on an incoming connection anyway?Otherwise
pip installsimply hangs with no output, regardless of verbosity level…The DNS solution does not work on Windows 10 with WSL2 and Ubuntu 20.04 and at this point you have to do what’s described in this stack overflow post just because the file gets overwritten but it doesn’t fix pip. What works is disabling the firewall which is only a temporary solution.
I have some issues with this too. My issues is pip install take too long to process (no output for 5 minute) after some searching I find that if i disable my Public Network Firewall it seems fine again.
Does anyone know how to allow the pip (wsl) in firewall. so i can turn on my public network firewall again ?
i already try what @Biswa96. but my
*/LocalStatefolder is empty. and already try what @iongion solution. but it still does not work.Hi, for me, the thing that fixed it was disconnecting my VPN connection and just connecting to wifi directly.
Works even if i use
condainstead of system python3. It seems the systempython3-keyringdid block something. By the way, before trying this, i have 2 conda environments with exactly the same version of python, pip, certifi packages, and one works originally while the other showed the pip networking issue. Now both work! 😃I now have the same issue, it has worked for a long time but now stopped working with latest updates.
It seems in my Ubuntu WSL, the pip belonging to my Miniconda’s base installation works fine, but when creating a new one
conda create -n myenv python=3and doingconda activate myenvandpip install somepippackageit shows the error.On win10, Education, ver. 20H2, build 19042.1165, I had network unreachable on pip. After checking and founding ping also returned network unreachable, I discovered that simply stopping the wireless connection and staying on Ethernet was the solution.
Hello, I am having the same issue. Pip hangs on every command except version.
I tried all the solutions here: I reinstalled everything, I turned off the firewall (I have the windows one turned off by default, I use Bitdefender and I also tried turning it off), I uninstalled keyring, I disabled IPv6 per a stack overflow post. Also a wild solution I found was to clear the DISPLAY variable, don’t know how it’s related but I tried with a functioning Xserver and a cleared variable.
My Windows is W10 Home Version 10.0.19042 Build 19042, WSL2 with Ubuntu 20.04 LTS from the Windows Store.
My pip install hangs on this:
Starting new HTTPS connection (1): pypi.org:443If I Ctrl C the operation, the traceback shows that it was hanging in this function:I has no problème with the network 😉. juste nothing when use “pip3” without “.exe” extension
Dis you try what @iongion did?
This is indeed speeding up the PIP related issues