Windows Version: 10 Pro, Version 20H2 (OS Build 19042.1165)
WSL Version: 2
Ubuntu Version: 20.04
I'm working with WSL 2 on my Windows laptop and am trying to install some Python packages (pytest
) using pip
. Specifically, I create an Anaconda environment with Python=3.7
and try to install the package within that environment. However, the command hangs for a while and then I get this warning:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f608eadaf90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pytest/
The same thing repeats until I press Ctrl-C. I originally had WSL version 1 installed and upgraded to WSL version 2. When I was using WSL version 1, I didn't have this problem. When I searched online, it seems several people have had similar (but slightly different in terms of the actual exception) problems, but I have not come across a solution that works for me.
I also found out that this is not just limited to pip
. I'm unable to clone gitlab
(from work) repositories as well. It results in a fatal error of not able to find the repository. I found a potential fix from here. It says to add a nameserver
to my /etc/resolv.conf
. This is my current /etc/resolv.conf
:
nameserver 1.1.1.1
I manually added the last line. As indicated in the file, I created /etc/wsl.conf
in order to stop this file automatically regnerate:
[network]
generateResolvConf = false
This works, howver, it takes a while for the command I issue to get going (git clone
, pip
etc).
I don't really understand what the issue is and why adding nameserver 1.1.1.1
solves it or why its being slow. Is there a fix for this?
Thanks.