Python 2.7 and 3.4 requests No module named ' zlib '

Source: Internet
Author: User
Tags openssl

Error phenomenon

The Python requests module is installed with an error in the following

[[email protected] ~]# echo  $PYTHONPATH [[email protected] ~]# [[email  protected] ~]# python27python 2.7.10  (default, oct  8 2015,  15:46:46)  [GCC 4.4.7 20120313  (red hat 4.4.7-4)] on linux2type  " Help ", " copyright ", " credits " or " license " for more information.>> > >>> import requestsTraceback  (most recent call last):   File  "<stdin>", line 1, in <module>  file  "/usr/ local/python27/lib/python2.7/site-packages/requests/__init__.py ",  line 58, in <module >    from . import utils  File  "/usr/local/python27/lib/ python2.7/site-packages/requests/utils.py ", line 26, in <module>     from .compat import parse_http_list as _parse_list_header  file  "/usr/local/python27/lib/ python2.7/site-packages/requests/compat.py ", line 7, in <module>     from .packages import chardet  File  "/usr/local/python27/lib/python2.7/ site-packages/requests/packages/__init__.py ", line 29, in <module>     import urllib3importerror: no module named urllib3>>> exit () [[ email protected] ~]# [[email protected] ~]# python34python 3.4.3  ( default, oct  8 2015, 15:22:41)  [GCC 4.4.7 20120313  (red hat  4.4.7-4)] on linuxtype  "Help",  "copyright",  "credits"  or  "license"  for more information.>>> >>> import requestsTraceback  ( most recent call  last):  file  "/usr/local/python34/lib/python3.4/site-packages/requests/packages/__init__.py",  line 27, in <module>    from . import urllib3   File  "/usr/local/python34/lib/python3.4/site-packages/requests/packages/urllib3/__init__.py",  line 10, in <module>    from .connectionpool import   (  File  "/usr/local/python34/lib/python3.4/site-packages/requests/packages/urllib3/ connectionpool.py ",  line 41, in <module>    from .response  import HTTPResponse  File  "/usr/local/python34/lib/python3.4/site-packages/requests/ packages/urllib3/response.py ",  line 2, in <module>    import  zlibImportError: No module named  ' zlib ' during handling of the  Above exception, another exception occurred:traceback  (most recent call last):   File   "<stdin>", line 1, in <module>  file  "/usr/local/python34 /lib/python3.4/site-packages/requests/__init__.py ", line 58, in <module>     from . import utils  File  "/usr/local/python34/lib/python3.4/ site-packages/requests/utils.py ",  line 26, in <module>    from  .compat import parse_http_list as _parse_list_header  File  "/usr/ local/python34/lib/python3.4/site-packages/requests/compat.py ", line 7, in <module>     from .packages import chardet  File  "/usr/local/python34 /lib/python3.4/site-packages/requests/packages/__init__.py ", line 29, in <module>     import urllib3importerror: no module named  ' URLLIB3 ' >>> 
Python 2.7.10 Workarounds
Yum-y Install Zlib-devel openssl-develcd/wls/softwares/python-2.7.10./configure--prefix=/usr/local/ Python27makemake Install
Verify
python 2.7.10  (default, oct  8 2015, 17:29:37)  [GCC 4.4.7  20120313  (red hat 4.4.7-4)] on linux2type  "Help",  "copyright",  " Credits " or " license " for more information.>>> >>> import  requests>>> r = requests.get (' https://10.25.7.2 ') traceback  (most  Recent call last):  file  "<stdin>",  line 1, in <module >  File  "/usr/local/python27/lib/python2.7/site-packages/requests/api.py",  line 69 ,  in get    return request (' Get ',  url, params=params, ** Kwargs)   File  "/usr/local/python27/lib/python2.7/site-packages/requests/api.py",  line  50, in request    response = session.request (Method=method,  url=url, **kwargs)  &nbsP file  "/usr/local/python27/lib/python2.7/site-packages/requests/sessions.py",  line 471, in  request    resp = self.send (Prep, **send_kwargs)   File   "/usr/local/python27/lib/python2.7/site-packages/requests/sessions.py",  line 579, in  send    r = adapter.send (Request, **kwargs)   File  "/ usr/local/python27/lib/python2.7/site-packages/requests/adapters.py ",  line 430, in send     raise sslerror (e, request=request) Requests.exceptions.sslerror: [ssl:  CERTIFICATE_VERIFY_FAILED] certificate verify failed  (_ssl.c:590) >>>  >>> r = requests.get (' https://10.25.7.2 ', Verify=false)/usr/local/python27/lib/ python2.7/site-packages/requests/packages/urllib3/connectionpool.py:789: insecurerequestwarning:  Unverified https request&nbsP;is being made. adding certificate verification is strongly advised.  see: https://urllib3.readthedocs.org/en/latest/security.html  insecurerequestwarning) > >> requests.packages.urllib3.disable_warnings () >>> r = requests.get (' HTTPS ://10.25.7.2 ', Verify=false) >>> r.status_code200>>>
Python 3.4.3 Workarounds
Yum-y Install Zlib-devel openssl-develcd/wls/softwares/python-3.4.3./configure--prefix=/usr/local/ Python34makemake Install
Verify
python 3.4.3  (default, oct  8 2015, 17:58:21)  [GCC 4.4.7  20120313  (red hat 4.4.7-4)] on linuxtype  "Help",  "copyright",  "credits " or " license " for more information.>>> >>> import  Requests>>> r = requests.get (' https://10.25.7.2 ', Verify=false)/usr/local/python34/lib/ python3.4/site-packages/requests/packages/urllib3/connectionpool.py:789: insecurerequestwarning:  unverified https request is being made. adding certificate  verification is strongly advised. see: https://urllib3.readthedocs.org/en/latest/ security.html  insecurerequestwarning) >>> requests.packages.urllib3.disable_warnings () >>> r = requests.get (' https://10.25.7.2 ', Verify=false) >>> r.status_ Code200>>>


Python 2.7 and 3.4 requests No module named ' zlib '

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.