【发布时间】:2017-10-08 03:43:29
【问题描述】:
我正在尝试在 Python 3 中导入和使用请求。当我导入请求时,我在 IDLE(以及 IntelliJ)中收到此错误:
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
编辑:我找到了一个临时解决方案并发布为我的问题的答案。但是欢迎/鼓励任何其他更好的解决方案的答案。谢谢。
【问题讨论】:
-
您应该将解决方案作为答案发布,而不是将其添加到问题中
-
@Andersson 我按照您的建议做了,并将解决方法移至答案。我还确认没有补丁,所以“1.22.0”应该是合适的。仍在寻求更好的解决方案,但可能没有。希望这可以帮助其他人。
标签: python-3.x web-scraping python-requests urllib3