2016-06-21 124 views
2

當我嘗試運行我的python腳本時,會發生此錯誤。我怎麼解決這個問題 ?Python 2.7.3 urllib2錯誤

['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'urllib2'] 
Traceback (most recent call last): 
    File "m.py", line 3, in <module> 
    import requests 
    File "/usr/local/lib/python2.7/dist-packages/requests-2.9.1-py2.7.egg/requests/__init__.py", line 58, in <module> 
    from . import utils 
    File "/usr/local/lib/python2.7/dist-packages/requests-2.9.1-py2.7.egg/requests/utils.py", line 26, in <module> 
    from .compat import parse_http_list as _parse_list_header 
    File "/usr/local/lib/python2.7/dist-packages/requests-2.9.1-py2.7.egg/requests/compat.py", line 38, in <module> 
    from urllib2 import parse_http_list 
ImportError: cannot import name parse_http_list 
+1

確實[這](http://stackoverflow.com/questions/32986626/python-requests-importerror-cannot-import-name-headerparsingerror)幫助在所有? –

回答

2

您需要升級requests

pip install --upgrade requests