pip,代理验证和“不支持的代理方案"; [英] pip, proxy authentication and "Not supported proxy scheme"

查看:86
本文介绍了pip,代理验证和“不支持的代理方案";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在新的python安装上安装pip.我陷入代理错误.看起来像是get-pipurllib3 ??

Trying to install pip on a new python installation. I am stuck with proxy errors. Looks like a bug in get-pip or urllib3??

问题是我是否必须经历如下所述设置 CNTLM的痛苦还是有捷径?

Question is do I have to go through the pain of setting up CNTLM as described here or is there a shortcut?

get-pip.py文档表示使用--proxy="[user:passwd@]proxy.server:port"选项指定代理和相关身份验证.但是似乎pip传递了整个内容,因为urllib3会将"myusr"解释为url方案,因为:"我猜是(?).

get-pip.py documentation says use --proxy="[user:passwd@]proxy.server:port" option to specify proxy and relevant authentication. But seems like pip passes on the whole thing as it is to urllib3 which interprets "myusr" as the url scheme, because of the ':' I guess (?).

C:\ProgFiles\Python27>get-pip.py --proxy myusr:mypswd@111.222.333.444:80
Downloading/unpacking pip
Cleaning up...
Exception:
Traceback (most recent call last):
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\commands\install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\req.py", line 1177, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\index.py", line 194, in find_requirement
    page = self._get_page(main_index_url, req)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\index.py", line 568, in _get_page
    session=self.session,
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\index.py", line 670, in get_page
    resp = session.get(url, headers={"Accept": "text/html"})
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\_vendor\requests\sessions.py", line 468, in get
    return self.request('GET', url, **kwargs)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\download.py", line 237, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\_vendor\requests\sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\_vendor\requests\sessions.py", line 559, in send
    r = adapter.send(request, **kwargs)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\_vendor\requests\adapters.py", line 305, in send
    conn = self.get_connection(request.url, proxies)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\_vendor\requests\adapters.py", line 215, in get_connection
    block=self._pool_block)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\_vendor\requests\packages\urllib3\poolmanager.py", line 258, in proxy_fro
m_url
    return ProxyManager(proxy_url=url, **kw)
  File "c:\users\sg0219~1\appdata\local\temp\tmpxwg_en\pip.zip\pip\_vendor\requests\packages\urllib3\poolmanager.py", line 214, in __init__
    'Not supported proxy scheme %s' % self.proxy.scheme
AssertionError: Not supported proxy scheme myusr

Storing debug log for failure in C:\Users\myusr\pip\pip.log

C:\ProgFiles\Python27>

当我在不使用usrname和密码的情况下运行命令时,它可以正常工作,但是代理拒绝该请求,要求其进行身份验证("407身份验证要求").

When I run the command without the usrname and password it works fine, but proxy rejects the request saying it needs authentication ("407 authenticationrequired").

C:\ProgFiles\Python27>get-pip.py --proxy 111.222.333.444:80
Downloading/unpacking pip
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement pip
Cleaning up...
No distributions at all found for pip
Storing debug log for failure in C:\Users\sg0219898\pip\pip.log

C:\ProgFiles\Python27>cat C:\Users\sg0219898\pip\pip.log
------------------------------------------------------------
C:\ProgFiles\Python27\get-pip.py run on 09/29/14 16:23:26
Downloading/unpacking pip
  Getting page https://pypi.python.org/simple/pip/
  Could not fetch URL https://pypi.python.org/simple/pip/: connection error: ('Cannot connect to proxy.', error('Tunnel connection failed: 407 authenticationrequired',))
  Will skip URL https://pypi.python.org/simple/pip/ when looking for download links for pip
  Getting page https://pypi.python.org/simple/
  Could not fetch URL https://pypi.python.org/simple/: connection error: ('Cannot connect to proxy.', error('Tunnel connection failed: 407 authenticationrequired',))
  Will skip URL https://pypi.python.org/simple/ when looking for download links for pip
  Cannot fetch index base URL https://pypi.python.org/simple/
  URLs to search for versions for pip:
  * https://pypi.python.org/simple/pip/
  Getting page https://pypi.python.org/simple/pip/
  Could not fetch URL https://pypi.python.org/simple/pip/: connection error: ('Cannot connect to proxy.', error('Tunnel connection failed: 407 authenticationrequired',))
  Will skip URL https://pypi.python.org/simple/pip/ when looking for download links for pip
  Could not find any downloads that satisfy the requirement pip
Cleaning up...
  Removing temporary dir c:\users\sg0219~1\appdata\local\temp\pip_build_SG0219898...
No distributions at all found for pip
Exception information:
Traceback (most recent call last):
  File "c:\users\sg0219~1\appdata\local\temp\tmp36ynxd\pip.zip\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "c:\users\sg0219~1\appdata\local\temp\tmp36ynxd\pip.zip\pip\commands\install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "c:\users\sg0219~1\appdata\local\temp\tmp36ynxd\pip.zip\pip\req.py", line 1177, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "c:\users\sg0219~1\appdata\local\temp\tmp36ynxd\pip.zip\pip\index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for pip

C:\ProgFiles\Python27>

我简要介绍了 urllib3\poolmanager.py 和似乎与用户名/密码无关.

I had a brief look at urllib3\poolmanager.py and it doesn't seem to have anything to do with username/passwords.

推荐答案

这是在抱怨URL的方案(urlparse理解为myusr),要解决此问题,您应该这样做:

This is complaining about the scheme for the URL (which urlparse is understanding to be myusr), to work around that you should instead be doing:

get-pip.py --proxy http://myusr:mypswd@111.222.333.444:80

这篇关于pip,代理验证和“不支持的代理方案";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆