简体   繁体   中英

Error when using requests In Python2.7

import requests
r = requests.get('http://bbs.byr.cn/')
print r

The error:

Traceback (most recent call last): File "E:\\MyPythonRoad\\src\\requeststest.py", line 1, in import requests File "C:\\Python27\\lib\\site-packages\\requests-2.3.0-py2.7.egg\\requests__init__.py", line 58, in from . import utils File "C:\\Python27\\lib\\site-packages\\requests-2.3.0-py2.7.egg\\requests\\utils.py", line 25, in from .compat import parse_http_list as _parse_list_header File "C:\\Python27\\lib\\site-packages\\requests-2.3.0-py2.7.egg\\requests\\compat.py", line 7, in from .packages import chardet File "C:\\Python27\\lib\\site-packages\\requests-2.3.0-py2.7.egg\\requests\\packages__init__.py", line 3, in from . import urllib3 File "C:\\Python27\\lib\\site-packages\\requests-2.3.0-py2.7.egg\\requests\\packages\\urllib3__init__.py", line 16, in from .connectionpool import ( File "C:\\Python27\\lib\\site-packages\\requests-2.3.0-py2.7.egg\\requests\\packages\\urllib3\\connectionpool.py", line 36, in from .connection import ( File "C:\\Python27\\lib\\site-packages\\requests-2.3.0-py2.7.egg\\requests\\packages\\urllib3\\connection.py", line 43, in from .util import ( ImportError: No module named util

requests

Since you are using Windows, you may want to try to reinstall requests through this binary .

urllib3

According to this , you may want to try manual download the util folder from urilib3 from the download at the bottom of pypi , and add it to the urllib3 install location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM