Skip to content

Fails to download from the internet if NSCI inticates offline #275

Closed

Description

@thatsprettygood

Install source and version

  • Installed from the Windows Store
  • Installed with the MSIX from python.org
  • Installed with the MSI from python.org
  • Installed with winget install 9NQ7512CXL7T

Version: 25.2

Describe the bug
It seems that it relies upon Windows's NSCI even if internet connectivity is available.

To Reproduce

  1. Disable NSCI by blocking the connectivity check URL
  2. Attempt to download python using the manager

Expected behavior
Recognize that internet connectivity is available.

Additional context
python_install_20260215213323_42144.log

Activity

  1. zooba commented on Feb 16, 2026

    @zooba
    Member

    Hmm, that error is coming from the OS's own download function, so we can't do anything much to override it - if the OS is refusing to download a file, then it's refusing.

    Can you try running with environment variable PYMANAGER_ENABLE_BITS_DOWNLOAD set to 0? That will skip the first method and try with the second - if the second also refuses to work, then we can't really work around this anyway, even if we were to try and detect the state of "connected but the OS thinks it is disconnected".

  2. thatsprettygood commented on Feb 16, 2026

    @thatsprettygood
    Author

    Yup, that works.
    It seems BITS will refuse to download anything if it thinks it's offline.
    There should probably be fallback behavior in place.

  3. zooba commented on Feb 16, 2026

    @zooba
    Member

    There is fallback behaviour - you just tested with it - we just don't use it when BITS reports that it failed because the internet isn't connected (since there's no point doing jittered/delayed retries when the problem is local).

    Until extra handling is added for that particular case, the workaround is to set the environment variable to skip BITS.

  4. thatsprettygood commented on Feb 16, 2026

    @thatsprettygood
    Author

    Should I keep the issue open until extra handling is implemented?

  5. zooba commented on Feb 16, 2026

    @zooba
    Member

    Yeah, we'll leave this open to keep track. Unless you want to have a go at implementing it (should be in urlutils.py), your work is done :)

  6. thatsprettygood commented on Feb 16, 2026

    @thatsprettygood
    Author

    I just use python for its tools, I am not skilled in programming. The only way I can think of implementing this would be to ping the download server with a fallback, and make that the default if success.

  7. thatsprettygood commented on Feb 16, 2026

    @thatsprettygood
    Author

    I checked the code and am I reading that it is supposed to fallback in the no internet case?

    LOGGER.verbose("Failed to download using BITS, " +
    "possibly due to no internet. Retrying with fallback method.")

  8. zooba commented on Feb 17, 2026

    @zooba
    Member

    Only if the function to check whether the OS thinks the internet is connected fails. These are the lines just above what you quoted:

    if not winhttp_isconnected():
    LOGGER.error("Failed to download. Please connect to the internet and try again.")
    raise RuntimeError("Failed to download. Please connect to the internet and try again.") from ex

    So basically, that previous check should be skipped and we should always try twice, even when the user is offline. We need to make sure that it still behaves reasonably when users are actually offline (no offence, but that scenario matters more than people who deliberately block the test domain), but if it just delays the final error message by a few milliseconds, then no real harm.

  9. added a commit that references this issue on Apr 15, 2026
    a532f60
  10. self-assigned this
    on Apr 15, 2026
  11. added a commit that references this issue on Apr 15, 2026
    68361e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions