2017-10-08 87 views
1

我試圖導入和Python 3的使用請求。當我輸入我的請求得到IDLE此錯誤(以及的IntelliJ):的Python 3個請求模塊錯誤:urllib3版本解析問題

Traceback (most recent call last): 
    File "<pyshell#0>", line 1, in <module> 
    import requests 
    File "/usr/local/lib/python3.6/site-packages/requests/__init__.py", line 49, in <module> 
    major, minor, patch = urllib3.__version__.split('.')[:3] 
ValueError: not enough values to unpack (expected 3, got 2) 

我已經閱讀並理解,在嘗試讀取需要三個值解包(主要,次要,補丁)的urllib3版本時,請求存在問題。不過,我的urllib3版本是1.22,最後沒有補丁。這裏是我的點凍結:

appnope==0.1.0 
beautifulsoup4==4.6.0 
bleach==2.0.0 
certifi==2017.7.27.1 
chardet==3.0.4 
chromedriver==2.24.1 
cycler==0.10.0 
Cython==0.26.1 
decorator==4.1.2 
entrypoints==0.2.3 
facebook-sdk==2.0.0 
geopy==1.11.0 
glob2==0.6 
html5lib==0.999999999 
idna==2.6 
ipykernel==4.6.1 
ipython==6.1.0 
ipython-genutils==0.2.0 
ipywidgets==7.0.0 
jedi==0.10.2 
Jinja2==2.9.6 
jsonschema==2.6.0 
jupyter==1.0.0 
jupyter-client==5.1.0 
jupyter-console==5.2.0 
jupyter-core==4.3.0 
MarkupSafe==1.0 
matplotlib==2.0.2 
mistune==0.7.4 
nbconvert==5.3.1 
nbformat==4.4.0 
nltk==3.2.4 
nose==1.3.7 
notebook==5.0.0 
numpy==1.13.1 
olefile==0.44 
opencv-python==3.3.0.10 
pandas==0.20.3 
pandocfilters==1.4.2 
pexpect==4.2.1 
pickleshare==0.7.4 
Pillow==4.2.1 
prompt-toolkit==1.0.15 
ptyprocess==0.5.2 
Pygments==2.2.0 
PyMySQL==0.7.11 
pyparsing==2.2.0 
python-dateutil==2.6.1 
pytz==2017.2 
pyzmq==16.0.2 
qtconsole==4.3.1 
requests==2.18.4 
requests2==2.16.0 
scikit-learn==0.19.0 
scipy==0.19.1 
selenium==3.6.0 
simplegeneric==0.8.1 
six==1.10.0 
sklearn==0.0 
terminado==0.6 
testpath==0.3.1 
tornado==4.5.2 
traitlets==4.3.2 
tzlocal==1.4 
urllib3==1.22 
virtualenv==15.1.0 
wcwidth==0.1.7 
webencodings==0.5.1 
widgetsnbextension==3.0.2 
xlrd==1.1.0 

編輯:我找到了一個臨時的解決方法,併發布爲我的問題的答案。但歡迎/鼓勵任何其他更好的解決方案。謝謝。

+0

您應該將解決方案作爲答案發布,而不是將其添加到問題中 – Andersson

+0

@Andersson我按照您的建議做了並將解決方法移至答案。我也確認沒有補丁,所以'1.22.0'應該是合適的。仍在尋求更好的解決方案,但可能沒有人會有。希望這可以幫助別人。 – Hanzy

回答

1

爲了得到要求的工作,我可以在我的項目/空閒會話的頂部是找到一種解決方法如下:

import urllib3 # Must append a third value to avoid error 
if len(urllib3.__version__.split('.')) < 3: 
urllib3.__version__ = urllib3.__version__ + '.0' 

訪問this link我能夠證實有後在撰寫本文時,沒有修正urllib3版本1.22。我假設一個補丁發佈時,這個解決方法不是必須的,但這可能會幫助有類似問題的人。