Fixing CERTIFICATE_VERIFY_FAILED when using yfinance's ticker.info

I've been using the excellent yfinance project (https://github.com/ranaroussi/yfinance) to get stock prices. However today when trying to read a ticker's basic information, it failed on me with:

File ".../venv/lib/python3.7/site-packages/pandas/io/html.py", line 848, in _parser_dispatch
raise ImportError("lxml not found, please install it")

So I pip install lxml and try again. This time I get this exception:

File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)>

It turns out it's because I am running Python on Mac OS and I need to install some certificates (https://stackoverflow.com/questions/42098126/mac-osx-python-ssl-sslerror-ssl-certificate-verify-failed-certificate-verify).

So I opened Finder and navigated to Applications, Python 3.7, then ran Install Certificates.command. And it worked indeed!