Python-requests ImportError: cannot import name HeaderParsingError

OS: Mac OS X. Wenn ich versuche, führen Sie den folgenden code, bekomme ich die Fehlermeldung:

ImportError: cannot import name HeaderParsingError

Ich angehängt habe traceback unten der code.

Ich habe versucht, dieses Problem zu lösen für 20 min nun auch mithilfe von Google und anderen stackoverflow. Ich habe versucht, läuft:

pip installieren urllib3 --upgrade

Ich hab auch schon versucht die Neuinstallation des Anfragen-Paket.

Es hat nicht geholfen.

Dies scheint ein Problem zu sein mit meinen Fragen oder urllib3 Paket. Hat jemand schon ein ähnliches Problem?

Code:

import requests
import json


def printResponse(r):
print '{} {}\n'.format(json.dumps(r.json(), sort_keys=True, indent=4,    separators=(',', ': ')), r)


r = requests.get('http://wikitest.orcsoftware.com/rest/api/content',
             params={'title': 'new page'},
             auth=('seb', '****'))
printResponse(r)
parentPage = r.json()['results'][0]
pageData = {'type': 'comment', 'container': parentPage,
        'body': {'storage': {'value': "<p>A new comment</p>", 'representation': 'storage'}}}
r =    requests.post('http://localhost:8080/confluence/rest/api/content',
              data=json.dumps(pageData),
              auth=('admin', 'admin'),
              headers=({'Content-Type': 'application/json'}))
printResponse(r)

Dies ist der traceback:

Traceback (most recent call last):
  File "/Users/sebastian/OneDrive/orc/restAPI/createSpace.py", line 1, in <module>
    import requests
  File "/Library/Python/2.7/site-packages/requests/__init__.py", line 61, in <module>
    from . import utils
  File "/Library/Python/2.7/site-packages/requests/utils.py", line 25, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/Library/Python/2.7/site-packages/requests/compat.py", ine 7, in <module>
    from .packages import charade as chardet
  File "/Library/Python/2.7/site-packages/requests/packages/__init__.py", line 3, in <module>
    from . import urllib3
  File "/Library/Python/2.7/site-packages/requests/packages/urllib3/__init__.py", line 16, in <module>
    from .connectionpool import (
  File "/Library/Python/2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 33, in <module>
    from .connection import (
  File "/Library/Python/2.7/site-packages/requests/packages/urllib3/connection.py", line 41, in <module>
    from .util import (
  File "/Library/Python/2.7/site-packages/requests/packages/urllib3/util/__init__.py", line 4, in <module>
    from .response import is_fp_closed
  File "/Library/Python/2.7/site-packages/requests/packages/urllib3/util/response.py", line 3, in <module>
    from ..exceptions import HeaderParsingError
ImportError: cannot import name HeaderParsingError
bitte formatieren Sie den code.
nicht sicher, was du meinst. Ich habe den code in der empfohlenen Art und Weise. Ist etwas falsch mit den tabs? Es funktioniert mit meiner IDE (pyCharm).
ja die Einrückung problem im code.
Nicht sicher, wie Sie Sie bekommen in diesem Zustand, aber du wirst neu installieren müssen requests selbst; es enthält eine version von urllib3 im requests/packages - Verzeichnis. Es ist requests/packages/urllib3/exceptions.py dass die Ursache für dieses Problem hier.
danke, werde es versuchen.

InformationsquelleAutor seb | 2015-10-07

Schreibe einen Kommentar