2014-09-29 72 views
6

尝试在新的python安装上安装pip。我被代理错误卡住了。看起来像是get-pipurllib3中的一个bug?pip,代理验证和“不支持的代理方案”

问题是我必须经历设置CNTLM as described here的痛苦还是有捷径?

get-pip.py documentation说使用--proxy="[user:[email protected]]proxy.server:port"选项来指定代理和相关认证。但似乎像点通过整个事情,因为它是urllib3它解释“myusr”作为URL方案,因为':'我猜(?)。

C:\ProgFiles\Python27>get-pip.py --proxy myusr:[email protected]: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 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有过短暂的外观和它似乎不具备任何与用户名/密码。

+1

看起来它可能与https://github.com/kennethreitz/requests/issues/2247 – shazow 2014-09-29 22:10:44

+0

有关。事实并非如此。请看下面的答案 – 2014-09-30 14:22:53

回答

10

这是抱怨的URL方案(其中urlparse被理解为myusr),来解决你应该改为做:

get-pip.py --proxy http://myusr:[email protected]:80 
1

这是因为脚本需要的环境变量HTTP_PROXY或者https_proxy包含URL中的方案。设置环境变量

export http_proxy="http://<hostname>:<port>" 
export https_proxy="https://<hostname>:<port>" 

之前运行“蟒蛇get-pip.py”

+0

这对我来说不起作用,但是它与'--proxy'选项一起工作。 – dokaspar 2017-10-03 10:43:42

+0

这对我有用。我得到与OP相同的错误,并且使用了不包含'http' /'https'的代理环境变量。使用'--proxy'选项对我不起作用,但这可能是由于我的环境变量仍然存在。 – JGC 2017-11-14 15:57:26

0

对于你提到的问题,这取决于如何在代理服务器认证已设置。 例如,我的内部网使用Windows AD,并且可能代理服务器正在使用Windows集成身份验证。因此,当我做pip install --proxy http://<server-ip>:<port> <module-name>,它工作正常。请注意,我不必输入用户名&密码,可能是由于集成的身份验证。

因此,您需要找出您的代理服务器正在使用的身份验证。您可以使用Fiddler(或任何其他网络分析器)工具来检查407响应中的WWW-Authenticate标头,以检查auth机器服务器支持。

+0

和OP一样,我的服务器期望用户/密码。无论如何,这个问题是被接受的答案指出的,并指出如何处理auth。 – Kashyap 2017-05-06 04:06:58