2014-09-29 10 views
6

Versucht, pip auf einer neuen Python-Installation zu installieren. Ich stecke mit Proxy-Fehlern fest. Sieht aus wie ein Fehler in get-pip oder urllib3?Pip, Proxy-Authentifizierung und "Nicht unterstützte Proxy-Schema"

Frage ist, muss ich durch die Schmerzen der Einrichtung gehen CNTLM as described here oder gibt es eine Verknüpfung?

get-pip.py documentation sagt Verwendung --proxy="[user:[email protected]]proxy.server:port" Option Proxy und relevante Authentifizierung angeben. Aber es scheint so, als ob pip die ganze Sache weitergibt, wie es urllib3 ist, die "myusr" als das URL-Schema interpretiert, wegen des ":" ich denke (?).

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> 

Wenn ich den Befehl ohne die usrname und Passwort es gut funktioniert, aber Proxy lehnt den Antrag sagen Authentifizierung es braucht („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> 

Ich hatte einen kurzen Blick auf urllib3\poolmanager.py und es scheint nicht, etwas mit Benutzername/Passwort zu tun zu haben.

+1

Sieht aus wie es mit https://github.com/kennethreitz/requests/issues/2247 – shazow

+0

verwandt sein könnte ist es nicht. Bitte sehen Sie die Antwort unter –

Antwort

10

Dies wird über das Programm für die URL beschweren (die urlparse ist das Verständnis myusr zu sein), dass man stattdessen tun sollten, arbeiten um:

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

Dies ist, da das Skript die Umgebungsvariablen erfordert http_proxy oder https_proxy enthält das Schema in der URL. Stellen Sie die Umgebungsvariablen

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

vor der „Python get-pip.py“ laufen

+0

Das hat für mich nicht funktioniert, aber es funktionierte mit der '--proxy' Option. – dokaspar

+0

Das hat für mich funktioniert. Ich bekam den gleichen Fehler wie das OP, und ich benutzte Proxy-Umgebungsvariablen, die nicht die "http"/"https" enthielten. Die Verwendung der '--proxy' Option funktionierte nicht für mich, aber das könnte daran liegen, dass meine Umgebungsvariablen noch existierten. – JGC

0

Für das Problem, das Sie erwähnt haben, hängt davon ab, wie der Proxy-Server-Authentifizierung eingerichtet wurde. Zum Beispiel verwendet mein Intranet Windows AD und wahrscheinlich verwendet der Proxy-Server Windows Integrated Auth. Also, wenn ich pip install --proxy http://<server-ip>:<port> <module-name> mache, funktioniert es gut. Beachten Sie, dass ich den Benutzernamen & nicht eingeben musste, wahrscheinlich aufgrund der integrierten Authentifizierung.

So müssen Sie herausfinden, die Authentifizierung von Ihrem Proxy-Server verwendet wird. Sie können Fiddler (oder einen anderen Netzwerkanalysator) Tool verwenden, um die WWW-Authenticate-Header in der Antwort 407 zu überprüfen, welche Auth Mechs, die der Server unterstützt.

+0

Wie in OP erwartet mein Server Benutzer/Passwort. Jedenfalls war das Problem, worauf die akzeptierte Antwort hinwies, und bemerkte, dass es mit Auth als solcher zu tun hatte. – Kashyap