nbdev icon indicating copy to clipboard operation
nbdev copied to clipboard

I get an "SSL certificate verify failed" error while using the nbdev_new

Open danielazamorah opened this issue 1 year ago • 1 comments

Hello! Probably a very silly issue. But I get the following error while using nbdev_new on a new repository:

File "/Users/admin/mambaforge/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain

I tracked the error back to the code of the nbdev_new procedure in the nbdev package. Apparently, there's an error when opening a URL.

The exact line that is not working (helper function used in nbdev_new): https://github.com/fastai/nbdev/blob/cf5e6a52b1393466a3b75c5ec69e2db9ebf77e47/nbdev/cli.py#L56

I found pages like this one on the web: https://www.howtouselinux.com/post/ssl-certificate_verify_failed-in-python, but would really appreciate it if someone can help me find the best way to solve this issue. I'm eager to start using nbdev.🚀

PS: We can later add a callout to the docs if this is something that happens to others.

danielazamorah avatar Feb 26 '23 04:02 danielazamorah

I also encountered the same problem, and I saw the following sentence in the error message:

     File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nbdev/cli.py", line 90, in nbdev_new
    tag = GhApi(gh_host='https://api.github.com', authenticate=False).repos.get_latest_release('fastai', 'nbdev-template').tag_name

I tried to change 'authenticate=False' to 'authenticate=True', The 'settings.ini' file was generated in the project. However, the problem remains:

  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/nbdev_new", line 8, in <module>
    sys.exit(nbdev_new())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fastcore/script.py", line 119, in _f
    return tfunc(**merge(args, args_from_prog(func, xtra)))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nbdev/cli.py", line 90, in nbdev_new
    tag = GhApi(gh_host='https://api.github.com', authenticate=True).repos.get_latest_release('fastai', 'nbdev-template').tag_name
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ghapi/core.py", line 61, in __call__
    return self.client(self.path, self.verb, headers=headers, route=route_p, query=query_p, data=data_p)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ghapi/core.py", line 120, in __call__
    res,self.recv_hdrs = urlsend(path, verb, headers=headers or None, debug=debug, return_headers=True,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fastcore/net.py", line 218, in urlsend
    return urlread(req, return_json=return_json, return_headers=return_headers)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fastcore/net.py", line 117, in urlread
    with urlopen(url, data=data, headers=headers, timeout=timeout, **kwargs) as u: res,hdrs = u.read(),u.headers
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/fastcore/net.py", line 108, in urlopen
    try: return urlopener().open(urlwrap(url, data=data, headers=headers), timeout=timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  ......

jumbojing avatar Feb 27 '23 21:02 jumbojing