简体   繁体   中英

SSL certificate problem when using wptools

I am getting the following error message when using wptools on Jupyter on Udacity.

error: (60, 'SSL certificate problem: certificate has expired')

This is the code.

import wptools
page = wptools.page('E.T._the_Extra-Terrestrial').get()

When I run that I get the following message.

en.wikipedia.org (query) E.T._the_Extra-Terrestrial
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-2-5bef4afd1ab8> in <module>()
----> 1 page = wptools.page('E.T._the_Extra-Terrestrial').get()

/opt/conda/lib/python3.6/site-packages/wptools/page.py in get(self, show, proxy, timeout)
    459             self.flags['defer_imageinfo'] = True
    460 
--> 461             self.get_query(False, proxy, timeout)
    462             self.get_parse(False, proxy, timeout)
    463 

/opt/conda/lib/python3.6/site-packages/wptools/page.py in get_query(self, show, proxy, timeout)
    574             raise ValueError("get_query needs title or pageid")
    575 
--> 576         self._get('query', show, proxy, timeout)
    577 
    578         return self

/opt/conda/lib/python3.6/site-packages/wptools/core.py in _get(self, action, show, proxy, timeout)
     95         qstr = self._query(action, qobj)
     96         req = self._request(proxy, timeout)
---> 97         response = req.get(qstr, qobj.status)
     98 
     99         self.cache[action]['query'] = qstr

/opt/conda/lib/python3.6/site-packages/wptools/request.py in get(self, url, status)
     74             print("Requests DISABLED", file=sys.stderr)
     75         else:
---> 76             return self.curl_perform(crl)
     77 
     78     def curl_perform(self, crl):

/opt/conda/lib/python3.6/site-packages/wptools/request.py in curl_perform(self, crl)
     82         bfr = BytesIO()
     83         crl.setopt(crl.WRITEFUNCTION, bfr.write)
---> 84         crl.perform()
     85         info = curl_info(crl)
     86         if info:

error: (60, 'SSL certificate problem: certificate has expired')

I am also unable to install wptools on Windows 10 to test it locally to check if it is something wrong with Udacity's Jupyter.

The issue

Kindly provide the error message you encountered when trying to download wptools on your Windows 10.

I had a similar issue with the Udacity workspace. I later found out that the issue is currently as of 14th June 2022, a technical issue on Udacity, I learnt it has been reported and the technical team has been informed.

What I did

  1. I downloaded the notebook ( .ipynb ) from the Udacity workspace
  2. I uploaded the downloaded .ipynb file and opened it on my local machine (Windows).
  3. I got an error also, but the error was because wptools is not pre-installed on Anaconda. So to do this I had to install it directly using pip as it is here .

on the first cell of your notebook, you can just use !pip install wptools

  1. With that installed you can remove the code !pip install wptools so you won't have to reinstall it anytime you run that cell.

That was how I did mine, and it worked fine on my Windows 10.

As wikipedia.org is signed by LetsEncrypt, and one of its CA certificates is expired: https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/

You need to remove the old DST root CA from your certificate store and add the ISRG root CA to your certificate store.

For Centos/Redhat, you can check your current CA in /etc/pki/tls/certs/ca-bundle.crt , for Debian/Ubuntu, you can check your current CA with command: sudo dpkg-reconfigure ca-certificates

I use Jupyter Notebook on Anaconda navigator.

在此处输入图像描述

I opened a new terminal to reinstall wptools on Anaconda environment

wptools on github

$ pip install wptools

then it worked fine !

You can use !pip install --upgrade certifi to upgrade the certificates. That should fix it.

I recently took a Udacity class where I encountered this same error. Here's what worked for me: Run !pip install --upgrade certifi in your Jupyter notebook (either Udacity workspace or on your local machine). Then run your wptools line again.

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