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

After installing python 3.x on Mac pip doesn't work at all #85643

Closed
peteje66 mannequin opened this issue Aug 4, 2020 · 7 comments
Closed

After installing python 3.x on Mac pip doesn't work at all #85643

peteje66 mannequin opened this issue Aug 4, 2020 · 7 comments
Labels
3.9 only security fixes 3.10 only security fixes OS-mac type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@peteje66
Copy link
Mannequin

peteje66 mannequin commented Aug 4, 2020

BPO 41471
Nosy @ronaldoussoren, @ned-deily, @miss-islington
PRs
  • [3.7] bpo-34272: Move argument parsing tests from test_capi to test_getargs2. (GH-8567) #8689
  • bpo-41471: Ignore invalid prefix lengths in system proxy settings on … #22762
  • [3.9] bpo-41471: Ignore invalid prefix lengths in system proxy settings on macOS (GH-22762) #22773
  • [3.8] bpo-41471: Ignore invalid prefix lengths in system proxy settings on macOS (GH-22762) #22774
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-10-20.07:18:20.804>
    created_at = <Date 2020-08-04.10:34:27.273>
    labels = ['OS-mac', '3.10', '3.9', 'type-crash']
    title = "After installing python 3.x on Mac pip doesn't work at all"
    updated_at = <Date 2020-10-20.07:18:20.804>
    user = 'https://bugs.python.org/peteje66'

    bugs.python.org fields:

    activity = <Date 2020-10-20.07:18:20.804>
    actor = 'ronaldoussoren'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-10-20.07:18:20.804>
    closer = 'ronaldoussoren'
    components = ['macOS']
    creation = <Date 2020-08-04.10:34:27.273>
    creator = 'peteje66'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41471
    keywords = ['patch']
    message_count = 7.0
    messages = ['374800', '374805', '378937', '378938', '378976', '379092', '379093']
    nosy_count = 4.0
    nosy_names = ['ronaldoussoren', 'ned.deily', 'miss-islington', 'peteje66']
    pr_nums = ['8689', '22762', '22773', '22774']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue41471'
    versions = ['Python 3.9', 'Python 3.10']

    @peteje66
    Copy link
    Mannequin Author

    peteje66 mannequin commented Aug 4, 2020

    Using pip fails with the same error messages independent of version an user. Also su or sudo -H doesn't change anything:
    How to Reproduce
    install python 3.x on your Mac and try pip

    After a quite long search I found that it is a problem with the proxy config. You need to remove all settings in network settings/proxy even those defining which domains shouldn't use a proxy. Proxy settings work fine with everything except python.

    xcode-select install
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    brew install pyenv
    pyenv install 3.7.3
    pip list --outdated or pip install something
    Exception
    xxx-MBP:~ xxx$ pip list --outdated
    Exception:
    Traceback (most recent call last):
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 179, in main
        status = self.run(options, args)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/commands/list.py", line 144, in run
        packages = self.get_outdated(packages, options)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/commands/list.py", line 152, in get_outdated
        dist for dist in self.iter_packages_latest_infos(packages, options)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/commands/list.py", line 152, in <listcomp>
        dist for dist in self.iter_packages_latest_infos(packages, options)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/commands/list.py", line 179, in iter_packages_latest_infos
        all_candidates = finder.find_all_candidates(dist.key)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/index.py", line 610, in find_all_candidates
        for page in self._get_pages(url_locations, project_name):
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/index.py", line 743, in _get_pages
        page = _get_html_page(location, session=self.session)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/index.py", line 229, in _get_html_page
        resp = _get_html_response(url, session=session)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/index.py", line 177, in _get_html_response
        "Cache-Control": "max-age=0",
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 546, in get
        return self.request('GET', url, **kwargs)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_internal/download.py", line 403, in request
        return super(PipSession, self).request(method, url, *args, **kwargs)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 524, in request
        prep.url, proxies, stream, verify, cert
      File "/Users/xxxx.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 700, in merge_environment_settings
        env_proxies = get_environ_proxies(url, no_proxy=no_proxy)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_vendor/requests/utils.py", line 761, in get_environ_proxies
        if should_bypass_proxies(url, no_proxy=no_proxy):
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip/_vendor/requests/utils.py", line 745, in should_bypass_proxies
        bypass = proxy_bypass(parsed.hostname)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/urllib/request.py", line 2610, in proxy_bypass
        return proxy_bypass_macosx_sysconf(host)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/urllib/request.py", line 2587, in proxy_bypass_macosx_sysconf
        return _proxy_bypass_macosx_sysconf(host, proxy_settings)
      File "/Users/xxx/.pyenv/versions/3.7.3/lib/python3.7/urllib/request.py", line 2573, in _proxy_bypass_macosx_sysconf
        if (hostIP >> mask) == (base >> mask):
    ValueError: negative shift count

    @peteje66 peteje66 mannequin added 3.8 only security fixes OS-mac type-crash A hard crash of the interpreter, possibly with a core dump labels Aug 4, 2020
    @ronaldoussoren
    Copy link
    Contributor

    I don't quite understand what the issue is.

    • What proxy settings do you have?

    • Is the problem reproducible without using pip?

      • By using the requests API to fetch a web page
      • By using the stdlib http.client API to do the same

    @ronaldoussoren
    Copy link
    Contributor

    The error is due to invalid proxy settings on the system.

    I can reproduce the error by enabling a HTTP proxy in system settings, while adding "172.19.0.0/40" to the proxy exclude list in the HTTP proxy settings.

    @ronaldoussoren ronaldoussoren added 3.9 only security fixes 3.10 only security fixes and removed 3.8 only security fixes labels Oct 19, 2020
    @ronaldoussoren
    Copy link
    Contributor

    I've tested the same settings with Safari, and that browser ignores excludes with an invalid prefix length.

    I've created a PR that does the same for urllib.request.

    @ronaldoussoren
    Copy link
    Contributor

    New changeset 93a1cca by Ronald Oussoren in branch 'master':
    bpo-41471: Ignore invalid prefix lengths in system proxy settings on macOS (GH-22762)
    93a1cca

    @ronaldoussoren
    Copy link
    Contributor

    New changeset aa7b03b by Miss Skeleton (bot) in branch '3.9':
    bpo-41471: Ignore invalid prefix lengths in system proxy settings on macOS (GH-22762) (GH-22773)
    aa7b03b

    @ronaldoussoren
    Copy link
    Contributor

    New changeset e7c5a43 by Miss Skeleton (bot) in branch '3.8':
    bpo-41471: Ignore invalid prefix lengths in system proxy settings on macOS (GH-22762) (GH-22774)
    e7c5a43

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes OS-mac type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant