问题
I'm trying to get started with yfinance for python, however, I can't seem to get a simple command to work for it.
import yfinance as yf
msft = yf.Ticker("MSFT")
print(msft.info)
hist = msft.history(period="5d")
When i try to run this it give me a whole bunch of errors I don't understand. The following errors below is only about one fifth of the actual errors, and I'm sure mods wouldn't be happy if I pasted it all in, I'm sure you get the point.
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/html.py", line 1101, in read_html
displayed_only=displayed_only,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/html.py", line 898, in _parse
tables = p.parse_tables()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/html.py", line 217, in parse_tables
tables = self._parse_tables(self._build_doc(), self.match, self.attrs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/html.py", line 736, in _build_doc
raise e
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/html.py", line 717, in _build_doc
with urlopen(self.io) as f:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/common.py", line 137, in urlopen
return urllib.request.urlopen(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
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)>
来源:https://stackoverflow.com/questions/63680032/yfinance-refusing-to-work-when-import-as-yf